I want to get input from user in an app that I code with pyqt5. The input I want to get must be either integer or float. So user shouldn't be able to enter anything else.
• If input is an integer, it must have a maximum 25 characters limit.
• If the input is a float, left of the dot must has maximum 25 characters limit, and the right of dot must has maximum 10 characters limit.
Methods I tried and didn't work :
I added “Double Spin Box” and then i set maximum value to 9999999999999999999999999.9999999999. Then, when I type 9999999999999999999999999.9999999999 as an input and click on an empty place, the input I typed changes to another number.
I added “Line Edit” and changed it “only integer mode” with this codes below:
from PyQt5.QtGui import QIntValidator
self.ui.lineEdit.setValidator(QIntValidator())
With the line edit I got, I can only get integer input. I can't get float input.
- I added “Line Edit” and i changed settings to 1000 character limit and only accepting integer input with the codes below:
rx = QtCore.QRegExp("[0-9]{1000}")
val = QtGui.QRegExpValidator(rx)
self.ui.LineEdit.setValidator(val)
With the line edit I got, I can only get integer input. I can't get float input.
- I added spinbox but i couldnt change spinbox’s maximum character limit to 25. And i cant get float input with spinbox.