Reputation: 13575
Is there any convenient way to input one QChar
character by some Qt widget? Using QLineEdit
need to convert QString
to QChar
and do some validation? Any char validator?
Upvotes: 0
Views: 575
Reputation: 2790
Either you should use QLineEdit::setMaxLength() or set a validator with QLineEdit::setValidator();
QRegExpValidator rv = new QRegExpValidator(QRegExp("^.$"));
lineEdit->setValidator(rv);
Upvotes: 2
Reputation: 25155
You can use the maxLength property to limit the input to one character:
lineEdit->setMaxLength(1);
For validation beyond that, implement your own QValidator.
Upvotes: 1