Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
6.1.2
-
None
Description
When doing a simple:
QLineEdit le; le.addAction(someIcon, QLineEdit::LeadingPosition); le.setClearButtonEnabled(true); le.setPlaceholderText(u"Search");
Then, the icon and placeholder text overlap like this:
(non-empty text also overlaps with the icon in this case)
I've been debugging this issue using the regular Qt 6.1.2 release in Visual Studio / Windows, and I found out it seems to come from:
QLineEditToolButton::needsSpace() returns m_wasHidden, which in the case of a regular leading action icon's widget, is never set to true, because the widget is not updated at the right moment, and does not have the right flags set.
m_wasHidden is set to true only with animateShow(true), which is never called in this case because:
- displayWidgets() is called in response to text change/edit: this is the first unexpected thing, we would expect the action icon's widget to be displayed and visible even with empty/placeholder text by default, and not just for non-empty text (there is a flag for that, which is not accessible when using the QLineEdit::addAction() API, so by default, we might expect the icon visibility to be independent from the text being empty)
- logically, the flag SideWidgetFadeInWithText is not set for the action, which is a second reason why the animateShow() is never called here. Seems logical indeed, but it creates the issue where we're not interrogating the right thing when checking for widget visibility
What seems wrong to me is the test that's done in effectiveTextMargin() when animation is enabled (which is in a regular Qt install). maybe a more elaborate condition is needed here, or a different logic, but clearly something's missing when calculating QLineEditPrivate::effectiveTextMargins().
Perhaps QLineEditIconButton::needsSpace() should be implemented like this:
bool needsSpace() const { return isVisible() || m_wasHidden; }
?
Attachments
Issue Links
- duplicates
-
QTBUG-94824 In qlinedit, icon and text overlap
- Closed