How to validate string in line edit
-
Many ways to do this. You can react to QLineEdit::textChanged() or use "QLineEdit::setValidator()":http://qt-project.org/doc/qt-4.8/qlineedit.html#setValidator for example.
-
Hi
I have used setValidator in textChanged() of LineEdit but it is not working consistently.
First time it works then if i switch to other window and come back then that line edit will allow all characters.ui.edit->setValidator(new QRegExpValidator(QRegExp("[a-z0-9]{1}[a-z0-9_-]{0,255}"),NULL));
What is going wrong?