PDA

View Full Version : IPAddress Validator RegExp



user_mail07
3rd April 2008, 02:36
Guys,

I have a little problem with regular expression validators. If I used below mentioned pIPAddressValidator for lineEdit1 or lineEdit2 it disables paste function upon right click action or CLT+V keyboard action. To make copy and paste function to work ..I have to acutally modify something in the lineEdit. From this case...The lineEdits on the dialog will be pre-populated with some IPAddresses. What if I just want to copy the text from lineEdit1 to lineEdit2 without modify or existing text...validator does not allow me to paste . I have tested removing setValidator(pIPAddressValidator) statement from my code then copy or paste works fine without any problem. Actually in right click menu copy or paste is enabled..it is just does not allow me to paste the selected text. But if I just click and modify a one digit the lineEdit..then paste works fine.


QString Octet = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";

QRegExp rx("^" + Octet + "\\." + Octet + "\\." + Octet + "\\." + Octet + "$");

pIPAddressValidator = new QRegExpValidator( rx, this );

lineEdit1->setValidator(pIPAddressValidator);
lineEdit2->setValidator(pIPAddressValidator);


I have using linux platform with Qt3. Is there something wrong with RegExp that I have been using but it validates Ip address fine.