Search code examples
qt4qlineedit

QValidator and keyboard language qt


I have a QLineEdit control, and wanna set validator for it.

QRegExp regExp("[A-Za-z0-9]+");
QRegExpValidator *regExpVal = new QRegExpValidator();
regExpVal->setRegExp (regExp);
ui->lineEditName->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 ?


Solution

  • You are trying to write those character which are not allowed to be entered into the conrtrol as per the regular expression. Either remove the regular expression or reset as per your countries script.

    Set QValidator::setLocale for vietnamese.And then set the regex to include vietnamese.