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

[QLineEdit] Methods text() and displayText() doesn't return the same value when inputMask is set.

    XMLWordPrintable

Details

    Description

      I one uses the methods text() and displayText() on a QLineEdit, the documentation states the it should return the same value. When a inputMask("HHHH;0") is set, the values are no longer the same.

      On Tue Jul 22 11:17:39 2008 Morten Engvoldsen wrote:

      • How to reproduce:
        1. Build and compile the code.
        2. Start the application
      • Expected result:
        Both labels should contain the same string "0100"
      • Actual result:
        One label sais "0100" and the other "1"

      Contents:

      #include <QtGui>
      class MainWidget : public QWidget {
      Q_OBJECT
      public:
      MainWidget();
      QLabel *label_1,*label_2;
      QLineEdit *lineEdit;
      };

      MainWidget::MainWidget(){
      lineEdit = new QLineEdit("0100",this);
      lineEdit->setInputMask("HHHH;0");

      label_1 = new QLabel(" String: '" + lineEdit->text() + "'");
      label_2 = new QLabel(" String: '" + lineEdit->displayText() + "'");

      QVBoxLayout *layout = new QVBoxLayout;
      layout->addWidget(lineEdit);
      layout->addWidget(label_1);
      layout->addWidget(label_2);
      setLayout(layout);
      }

      int main(int argc, char *argv[])

      { QApplication app(argc, argv); MainWidget mainWid; mainWid.show(); return app.exec(); }

      #include "main.moc"

      Attachments

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

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            engvolds Morten Engvoldsen (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes