Unsolved How to make lineEdit acceptable only integers?
-
Welcome, how can I validate QLineEdit objects which could only accept int numbers? Objects are added via Qt designer tool.
-
Hi
You can use
http://doc.qt.io/qt-5/qintvalidator.html#details -
How about using a QSpinBox?
-
Hi,
depending on your needs an input-mask may help. This can be set inside designer. Look for Input-mask in the Documentation of QLineEdit. -
@Gerd Could you give an simple example how to use this mask?
-
You can do something like this:
ui->yourLineEdit->setValidator( new QIntValidator(yourMin(0 for example), yourMax(100 for example), this) );
Here we have a qlineedit that will accept only integer from 0 to 100
-
Hi,
for an integer input between 0 and 100 set the mask to "009". Thats all.