if (d->m_validator == v)
return;
+ if (d->m_validator) {
+ qmlobject_disconnect(
+ d->m_validator, QValidator, SIGNAL(changed()),
+ this, QQuickTextInput, SLOT(q_validatorChanged()));
+ }
+
d->m_validator = v;
+ if (d->m_validator) {
+ qmlobject_connect(
+ d->m_validator, QValidator, SIGNAL(changed()),
+ this, QQuickTextInput, SLOT(q_validatorChanged()));
+ }
+
if (isComponentComplete())
d->checkIsValid();
emit validatorChanged();
}
+void QQuickTextInput::q_validatorChanged()
+{
+ Q_D(QQuickTextInput);
+ d->checkIsValid();
+}
+
#endif // QT_NO_VALIDATOR
void QQuickTextInputPrivate::checkIsValid()
QCOMPARE(dblInput->hasAcceptableInput(), true);
QCOMPARE(dblSpy.count(), 3);
+ // Changing the validator properties will re-evaluate whether the input is acceptable.
+ intValidator->setTop(10);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblSpy.count(), 4);
+ intValidator->setTop(12);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblSpy.count(), 5);
+
QQuickTextInput *strInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("strInput")));
QVERIFY(strInput);
QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged()));