validation - QRegExp for IP Address of QlineEDit in QT -
how can validate qlineedit control when want enter ip address qlineedit control, control should allow ip address . don't allow alphabets ,characters except dot(.) parts should in range of 0-255
ip address contain 4 parts , must 3 dots(.): first part should contain 3 digits.(must) second part should contain min 1 digit , max 3 digits.. third part should contain min 1 digit , max 3 digits. 4 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
you can make use of qregexpvalidator class. , regex this:
[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
after use qlineedit::setvalidator () function set validator.
hope helps...
Comments
Post a Comment