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

QLineEdit: Clear Button isn't properly drawn when enabled after setting text

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.5.0
    • 5.3.2, 5.4.1
    • None
    • Debian Testing x86_64, KDE 4.14.2, Qt 5.3.2 and Qt 5.4.1 as provided by qt.io
    • a34e9ebc1b908d31ba645688a8b0e9e53c2d3c6e

    Description

      When setting text on QLineEdit and then enabling clear button: the clear button is not drawn but present, i.e. it offsets the text as shown in qlineedit-bug-1.png (the empty space on the right) and when the area where the button is supposed to be is clicked – the text gets cleared. Also, when hovering above the invisible clear button the cursor doesn't changed as it should, i.e. it remains being Qt::IBeamCursor when it should have changed to Qt::ArrowCursor.

      When enabling clear button and then setting text on QLineEdit – everything works as expected: the button gets drawn and cursor changes (qlineedit-bug-2.png).

      Example code:

      main.cpp
      #include <QApplication>
      #include <QLineEdit>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QLineEdit line;
          line.setText("Some long long long long text"); // -- (1)
          line.setClearButtonEnabled(true);              // -- (2)
          line.show();
      
          return a.exec();
      }
      

      qlineedit-bug-1.png shows the result of the code as it is, while qlineedit-bug-2.png shows the result with lines of code marked as (1) and (2) being switched.

      When fixing this issue be sure to not re-introduce QTBUG-37548.

      Attachments

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

        Activity

          People

            peppe Giuseppe D'Angelo
            nurupo nurupo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes