How to make lineEdit acceptable only integers?
-
wrote on 8 Feb 2017, 11:26 last edited by
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 -
wrote on 8 Feb 2017, 11:32 last edited by
How about using a QSpinBox?
-
wrote on 8 Feb 2017, 11:42 last edited by
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. -
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.wrote on 8 Feb 2017, 18:08 last edited by@Gerd Could you give an simple example how to use this mask?
-
wrote on 8 Feb 2017, 20:23 last edited by
@testerius
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
-
wrote on 9 Feb 2017, 07:59 last edited by
Hi,
for an integer input between 0 and 100 set the mask to "009". Thats all.
1/7