Details
-
Bug
-
Resolution: Fixed
-
P4: Low
-
None
-
5.4.0
-
None
-
Windows 7
Description
Test the following code. Start typing to the upper textfield which uses own QValidator where text is changed to upper letters. textEdited() signal is not sent if validator changes the text.
http://qt-project.org/doc/qt-4.8/qlineedit.html#textEdited
This worked in Qt4.8 but not in Qt5.4
#include <QMainWindow> #include <QWidget> #include <QVBoxLayout> #include <QLineEdit> #include <QApplication> #include <QDebug> #include <QRegExp> #include <QRegExpValidator> class MyValidator : public QValidator { Q_OBJECT public : MyValidator(QObject *parent = 0) : QValidator(parent) { } public slots : State validate(QString &input, int &) const { input = input.toUpper() ; return(Acceptable) ; } } ; class MainWindow : public QMainWindow { Q_OBJECT public : MainWindow(QWidget *parent = 0) : QMainWindow(parent) { QWidget *w ; QVBoxLayout *lo ; QLineEdit *le ; MyValidator *myValidator ; QRegExpValidator *va2; w = new QWidget ; lo = new QVBoxLayout ; le = new QLineEdit(this) ; lo->addWidget(le) ; myValidator = new MyValidator(le) ; le->setValidator(myValidator) ; this->connect(le, SIGNAL(textEdited(const QString &)), SLOT(le_edited(const QString &))) ; this->connect(le, SIGNAL(textChanged(const QString &)), SLOT(le_changed(const QString &))) ; le = new QLineEdit(this) ; lo->addWidget(le) ; QRegExp rx("-?\\d{1,3}"); va2 = new QRegExpValidator(rx, le); le->setValidator(va2); this->connect(le, SIGNAL(textEdited(const QString &)), SLOT(le_edited(const QString &))) ; this->connect(le, SIGNAL(textChanged(const QString &)), SLOT(le_changed(const QString &))) ; w->setLayout(lo) ; this->setCentralWidget(w) ; } private slots : void le_edited(const QString &line) { qDebug() << __LINE__ << line << "edited" ; } void le_changed(const QString &line) { qDebug() << __LINE__ << line << "changed" ; } } ; #include "main.moc" int main(int argc, char **argv) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
Attachments
Issue Links
- resulted from
-
QTBUG-27347 QLineControl::fixup emits textEdited signal instead of textChanged
- Closed
For Gerrit Dashboard: QTBUG-44046 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
197888,8 | Ensure textEdited() is emitted if the input is changed by a validator | dev | qt/qtbase | Status: MERGED | +2 | 0 |