Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-15672

QLineEdit: setText will cause signal textEdited emitted when validator returns a different string

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 4.7.1
    • None

    Description

      #include <QtGui>
      
      class QUppercaseValidator : public QValidator
      {
      public:
      	QUppercaseValidator(QObject *parent) : QValidator(parent) {}
      	virtual State validate(QString &s, int &) const { fixup(s); return Acceptable; }
      	virtual void fixup(QString &s) const { s = s.toUpper(); }
      };
      
      int main(int argc, char *argv[])
      {
      	QApplication a(argc, argv);
      
      	QWidget w;
      	QLineEdit *edit1 = new QLineEdit;
      	QLineEdit *edit2 = new QLineEdit;
      	QLabel *label = new QLabel;
      	edit2->setValidator(new QUppercaseValidator(edit2));
      	QObject::connect(edit1, SIGNAL(textChanged(QString)), edit2, SLOT(setText(QString)));
      	QObject::connect(edit2, SIGNAL(textEdited(QString)), label, SLOT(setText(QString)));
      	QVBoxLayout *layout = new QVBoxLayout;
      	layout->addWidget(edit1);
      	layout->addWidget(edit2);
      	layout->addWidget(label);
      	w.setLayout(layout);
      
      	w.show();
      
          return a.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            anly Shouwei Niu
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes