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

QLineEdit Cursor show white line when use property of setInputMask

    XMLWordPrintable

Details

    • Linux/X11
    • 795ea19ca0a7e484793655b35f19de8dbc88e987 (qt/qtbase/dev) 443ce5d073f8cd32469fd74e705ca9465013ebcb (qt/qtbase/6.0) 0cf2f844760170ec8fd74591b298cef8ccf7c51c (qt/tqtc-qtbase/tqtc/lts-5.15)

    Description

      step1: phenomenon

      Create a QApplication and show QLineEdit,when QLineEdit use setInputMask property, the cursor show not right position. Sometimes there is a white line in the middle of the maskingput area, which is not particularly good for users.

      I tested on UOS1020, the phenomenon is same with Ubuntu19.04. on windows10, there's still something wrong with the cursor,Although it doesn't seem particularly obvious. (tested Qt version is Qt5.14.2, Qt5.15.1, Qt5.15.2, Qt6.0.0 )

      here is my test code and result(notRight.gif)

      #include <QApplication>
      #include <QLineEdit>
      
      // test code
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QLineEdit e;
          e.setInputMask("000:000:000:000");
          e.show();
      
          return a.exec();
      }
      

      step2: Expectation phenomenon

      hope QLineEdit cursor area show normal, when use setInputmask property.

      step3: Cause analysis

      QLineEdit Cursor Rect and InputMask area overlapping, the cursor rect area is white.because  drawCusor function's  QPainter    setCompositionMode   is  QPainter::RasterOp_NotDestination.

      step4: How to solve

      In fact, we should not care about the mode set when drawing. When inputmask is set, the cursor selects one character  at this time, and the cursor should not be drawn at this time, so we should add judgment conditions in qlineedit.cpp of  line 2077 :  d->control->inputMask().isEmpty()

       

      Attachments

        1. error.png
          error.png
          106 kB
        2. notRight.gif
          notRight.gif
          115 kB

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            kingderzhang kingderzhang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: