QLineEdit: disable cursor blinking on hide

QLineEdit activates the blinking cursor timer when it's shown,
but never deactivates it, resulting in constant wakeups even for
hidden line edits.

Note that this is a workaround. Qt is supposed to send a focus out
event to line edits that get hidden. In some corner cases, it
doesn't, and only a hide event is sent.

Change-Id: Ic0645512051466ca9b1e84c54cef34c22287338b
Task-number: QTBUG-52021
Pick-to: 6.6 6.5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit e35dcba5bb8cdcf578a514ad6e03ae64002c2c3a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2024-01-12 17:43:21 +01:00 committed by Qt Cherry-pick Bot
parent eeede2d800
commit 43362244a1

View File

@ -1462,6 +1462,8 @@ bool QLineEdit::event(QEvent * e)
|| style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this))
d->setCursorVisible(true);
}
} else if (e->type() == QEvent::Hide) {
d->control->setBlinkingCursorEnabled(false);
#if QT_CONFIG(action)
} else if (e->type() == QEvent::ActionRemoved) {
d->removeAction(static_cast<QActionEvent *>(e)->action());