Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to set validator for all lineEdit in application ?
Sparkle24 last edited by
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:
But I want to set 90 lineEdits validator at once...
Sam last edited by
You can subclass QLineEdit and create your own custom lineEdit class, then set the validator inside your custom class and use it whereever its needed.
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*>() )
giesbert last edited by
If you only want to have doubles there, why not use "QDoubleSpinBox":http://qt-project.org/doc/qt-4.8/qdoublespinbox.html instead?