PDA

View Full Version : QLineEdit-how to validate immediately?-connection problem



deepakn
20th August 2008, 06:22
Hello all,
I am trying to build a small app which has several IP Address fields. I have found the validation method [some kind of work around ] which i have put as Dialog::validateIP()

Now, i tried to connect the LineEdit to the function using many available signals. But none of them worked. Could anyone please tell what the problem is?

connect statements i have tried:

connect(sourceIPEdit, SIGNAL(lostFocus()), this, SLOT(validateIP()));
//connect(srcipEdit, SIGNAL(editingFinished()), this, SLOT(validateIP()));
//connect(srcipEdit, SIGNAL(textChanged()), this, SLOT(validateIP()));


Interesting thing is that if i connect the same func to a pushButton, it does work! What i am trying to achieve is to tell the user immediately after he left the sourceIPEdit field that he did something wrong. [Just like in some webforms where you get immediate feedback that, say for example, some username you have given is 'available']

Also, is there any way around to give a *silent* feedback to the user? without popping up a nagging error messagebox everytime?

I am using Qt 4.2.2 from Windows and Linux.

Deepak

wysota
20th August 2008, 07:15
Why not use a subclass of QValidator instead of hand-crafted solution? There are a few IPV4 validators available on the forum, if you search for IPV4Validator, you'll surely find them.