[SOLVED] How to allow ONLY numbers being entered in qlineedit in Chinese mode?
I have a qlineedit that only accepts numbers. I added QValidator such as the code below:
QLineEdit *edit = ui->lineEdit_2;
QValidator *validator = new QIntValidator(1,13999999);
But if i change the language to Chinese, i am able to enter Chinese characters into the qlineedit too! Does anyone know how to prevent such thing from happening?
What does this code return in your environment?
int pos = 0;
QIntValidator v(1, 13999999, this);
str = "String in Chinese";
qDebug() << v.validate(str, pos);
Why not just use a QSpinBox ?
thanks SGaist, I think i will just use QSpinbox instead.
Btw when I put QSpinbox, there's always a number there, like 0 or 1. How do I make it disappear?
Do you mean you want an empty QSpinBox ?
yes thats right
I have found this thread: