PDA

View Full Version : QT Designer : Accept only numbers for IP Address



QT_Vishwanath
7th August 2017, 07:36
Hi Qtfolks,

I am developing a QT GUI which accepts the IP Address, MAC address and Port number and validates them. The designer is as follows.

12538


But I want the Line edit for IP address and MAC Address should be as follows.

12539

Note : Newbie for the QT, please excuse if question doesn't make sense.

high_flyer
7th August 2017, 09:56
QLineEdit has this and some o ther validators built in, look at the docs - look for inputMask there.
Or you can make your own validator with QValidator

Gokulnathvc
8th August 2017, 14:08
Hi Qtfolks,

I am developing a QT GUI which accepts the IP Address, MAC address and Port number and validates them. The designer is as follows.

12538


But I want the Line edit for IP address and MAC Address should be as follows.

12539

Note : Newbie for the QT, please excuse if question doesn't make sense.


QRegExp rx("\\d+");
QLineEdit *myEdit = new QLineEdit();
myEdit ->setValidator(validator);
this->setCentralWidget(myEdit );