How to allow QLineEdit from Designer to accept only integer in the range 0 to 255?

3.5k views Asked by At

QT version 5.1

I have 2 issues:

1) I am wondering is there is any way I can set QLineEdit widget to accept only integer in the range from 0 < x < 255 from QT DESIGNER. I guess Input Mask can do this thing for us but wondering how ?

2) Only if we can't set values from QT designer, then in that case I have to do it from the source code. For that in which files will i make the changes?

Below is brief description of my project:

i) I have designed a GUI on QT designer with lots of QLineEdit widgets and buttons, checkbox etc.

ii) I am aware that there is QValidator class exist which can solve my problem . I know how to use QValidator but wondering just in case if I can't set validation of QLineEdit from Gui then I have to do it from source code. This is not a problem but where will I add my validation code in source code?

Should I add this in the constructor of GUI?

0

There are 0 answers