There is a method to set a validator to a QLineEdit:
void QLineEdit::setValidator(const QValidator *v)
Since the documentation does not contain many infos, I have some questions:
Is it safe to use the same Validator for more than one QLineEdit?
ui.edit1->setValidator(doubleValidator );
ui.edit2->setValidator(doubleValidator );
ui.edit3->setValidator(doubleValidator );
ui.edit4->setValidator(doubleValidator );
QDoubleValidator* doubleValidator = new QDoubleValidator(this);
ui.edit1->setValidator(doubleValidator );
ui.edit2->setValidator(doubleValidator );
ui.edit3->setValidator(doubleValidator );
ui.edit4->setValidator(doubleValidator );
To copy to clipboard, switch view to plain text mode
I've read the sourcefile (qt 4.4.0) and saw that the QLineEdit class removes the const of the QValidator* v so it looks that the QLineEdit changes the validator...
Does an old validator gets deleted if I set a new one?
ui.edit1->setValidator( new QDoubleValidator(this) );
ui.edit1->setValidator( new QDoubleValidator(this) );
To copy to clipboard, switch view to plain text mode
Thanks
Bookmarks