QIntValidator not Working as Im expecting
-
QIntValidator not Working as Im expecting
Im set the validation on LineFdit like thisintValidator = new QIntValidator(1,999, this);
intValidator->setTop(999);
intValidator->setBottom(1);
uiPoMo->lineEdit_stId1->setValidator(intValidator);but still LineEdit field accepting '0' and '+' ..?
I want to accept only 1 to 999 integer value.
Thanks in Advance.
-
@Pranit-Patil
set an Input mask as well, something like:... uiPoMo->lineEdit_stId1->setInputMask("00D"); uiPoMo->lineEdit_stId1->setValidator(intValidator);
-
You might want to take a look at this:
https://www.ics.com/blog/qt-support-input-masks-and-validators
The article is QML based, but the principles are the same and its a pretty good explanation.
-
@VRonin said in QIntValidator not Working as Im expecting:
uiPoMo->lineEdit_stId1->setValidator(new QRegularExpressionValidator(QRegularExpression("[1-9]\d{0,2}"),this));
Its works for me
Thank you so much to all.