[SOLVED] How to allow ONLY numbers being entered in qlineedit in Chinese mode?
-
Hi,
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);
edit->setValidator(validator);
@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?
Thank you!
-
Hi,
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:
http://qt-project.org/faq/answer/how_can_i_set_an_empty_default_value_in_qspinbox