How to validate string in line edit
I want to check if the input string in line edit starts with only alphabet or number.
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.
If you do not want to block the input so that he cannot write anything other than alphabet or number, you could check this with QLineEdit::editingFinished() and if the string is not valid display a message
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.
What is going wrong?