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

QLineEdit::PasswordEchoOnEdit text deleted on Linux

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.6, 6.7.0
    • None
    • Linux
    • Linux/X11

    Description

      QLineEdit text will be deleted on Linux switching QLineEdit::setEchoMode, default focused QWidget seems involved in this issue.

      An example to reproduce this issue.

      #include <QApplication>
      #include <QStyle>
      #include <QWidget>
      #include <QFormLayout>
      #include <QPushButton>
      #include <QLineEdit>
      
      int main(int argc, char *argv[])
      {
          QApplication *app = new QApplication(argc, argv);
      
          QWidget *widget = new QWidget();
          widget->setWindowTitle("QLineEdit::PasswordEchoOnEdit test");
          widget->setMinimumSize(360, 280);
      
          QFormLayout *form = new QFormLayout(widget);
          QPushButton* btn = new QPushButton();
          btn->setText("Submit");
          btn->setDefault(true);
      
          // initial text with PasswordEchoOnEdit will be deleted on linux
          //QLineEdit *wid = new QLineEdit("password");
      
          QLineEdit *wid = new QLineEdit();
      
          QAction *act = wid->addAction(QApplication::style()->standardIcon(QStyle::SP_ArrowUp), QLineEdit::TrailingPosition);
          wid->setEchoMode(QLineEdit::PasswordEchoOnEdit);
      
          QApplication::connect(act, &QAction::triggered, [=]()
          {
              if (wid->echoMode() == QLineEdit::Normal)
              {
                  wid->setEchoMode(QLineEdit::PasswordEchoOnEdit);
                  act->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp));
              }
              else
              {
                  wid->setEchoMode(QLineEdit::Normal);
                  act->setIcon(QApplication::style()->standardIcon(QStyle::SP_BrowserStop));
              }
          });
      
          form->addRow("Username", new QLineEdit());
          form->addRow("Password", wid);
          form->addRow(btn);
      
          // the issue ie. changing focus
          // calling QLineEdit::setEchoMode text will be deleted on linux
          btn->setFocus();
      
          wid->setEchoMode(QLineEdit::PasswordEchoOnEdit);
          wid->setText("password");
      
          widget->setLayout(form);
          widget->show();
      
          return app->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
            ctlcltd Leonardo Laureti
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes