PDA

View Full Version : Problem with QValidator and keyboard



vhptt
6th August 2012, 15:29
I have a QLineEdit control, and wanna set validator for it.

ui->lineEdit->setValidator(new QIntValidator(5,20, this));
So, I can't type any alphabet or special character on the lineEdit.
Problem is: I use scim-unikey as my keyboard software. When I change from English keyboard to Vietnamese keyboard, I still type alphabet character (not special character) on the lineEdit.
The character display on the lineEdit but when I focus mouse on another control, ther character disappear (I think this is right because I set QIntValidator for the lineEdit).
I wouldn't like the alphabet character display on the lineEdit. How can I fix this ?

sonulohani
7th August 2012, 07:39
use eventfilter instead.

vhptt
7th August 2012, 11:01
use eventfilter instead.
I dont know what you mean. Plz give me an example.

New problem:

QRegExp regExp("[A-Za-z0-9]+");
QRegExpValidator *regExpVal = new QRegExpValidator();
regExpVal->setRegExp (regExp);
ui->lineEditName->setValidator (regExpVal);
ui->lineEditAlias->setValidator (regExpVal);
After do that, I cant type any alphanumeric character on lineEditName and lineEditAlias with Vietnamese keyboard. Qt always clear the character I've input.
How can I fix this ?