QLineEdit *lineEdit = new QLineEdit(); QDoubleValidator *validator = new QDoubleValidator(0, 100, 2, lineEdit); lineEdit->setValidator(validator);
QSpinBox *spinBox = new QSpinBox(); QDoubleValidator *validator = new QDoubleValidator(-10, 10, 2, spinBox); validator->setNotation(QDoubleValidator::ScientificNotation); spinBox->setValidator(validator);
QLabel *label = new QLabel(); QDoubleValidator *validator = new QDoubleValidator(-99999999, -0.000000001, 9, label); label->setValidator(validator);The QDoubleValidator class is part of the QtCore library, which is part of the Qt framework.