Reputation: 61
How we can validate for QlineEdit control when i want to enter the IP Address into QlineEdit control, that control should be allow only IP address . don't allow any alphabets ,characters except dot(.) All the parts should be in range of 0-255
IP Address contain four parts and must three dots(.): first part should contain 3 digits.(must) second part should contain min 1 digit and max 3 digits.. third part should contain min 1 digit and max 3 digits. four part should contain minimun 1 digit.
ex: 122.234.245.211 121.112.112.44 255.255.136.132 133.231.123.2 255.0.0.0 121.0.0.23
Below ADDRESS should not accept: should give errorMessage bOx
ex: 24.253.321.422 442.445.552.444 23535.35.353.33 3532.333.332
Upvotes: 0
Views: 2503
Reputation: 730
You can make use of QRegExpValidator class. And regex as like this:
[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
After that use QLineEdit::setValidator () function to set validator.
Hope that helps...
Upvotes: 1