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

QLineEdit textEdited() and inputMask

    XMLWordPrintable

Details

    Description

      Setting an inputmask on a lineedit will cause textEdited to be emitted.

      This example demonstrates it.

      #include <QDebug>
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      public:
          MainWindow(QWidget *parent = 0)
              : QMainWindow(parent)
          {
              setCentralWidget(edit = new QLineEdit(this));
              connect(edit, SIGNAL(textEdited(QString)), this, SLOT(onTextEdited()));
              flipTimer.start(2000, this);
          }
          void timerEvent(QTimerEvent *e)
          {
              if (e->timerId() == timer.timerId()) {
                  edit->setStyleSheet(QString());
                  timer.stop();
              } else if (e->timerId() == flipTimer.timerId()) {
                  edit->setInputMask(edit->inputMask().isEmpty() ? "000.000.000.000;_" : 0);
              } else {
                  QMainWindow::timerEvent(e);
              }
          }
      public slots:
          void onTextEdited()
          {
              edit->setStyleSheet("background: red");
              timer.start(1000, this);
          }
      private:
          QBasicTimer timer, flipTimer;
          QLineEdit *edit;
      };
      
      #include "main.moc"
      
      
      int main(int argc, char **argv)
      {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();
          return a.exec();
      }
      

      Attachments

        For Gerrit Dashboard: QTBUG-1266
        # Subject Branch Project Status CR V

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            rve Anders Bakken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes