How to set validator for all lineEdit in application ?
-
My application has 90 lineEdit widget. I want to set QDoubleValidator for every lineEdit.
So how can I do that ? I can set individual I mean something like:
@QLineEdit::setValidator(new QDoubleValidator(this)
ui->lineEdit->setValidator(new QDoubleValidator(this))@
But I want to set 90 lineEdits validator at once... -
if you really have to do it at all at once and not as sam suggested you could do the following (for each widget without a parent):
@
foreach(QLineEdit* lineEdit, mainWindow.findChildren<QLineEdit*>() )
lineEdit->setValidator(new QDoubleValidator(lineEdit));
@ -
If you only want to have doubles there, why not use "QDoubleSpinBox":http://qt-project.org/doc/qt-4.8/qdoublespinbox.html instead?