Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.2, 6.0.0
-
-
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()