QPushButton: if mouse tracking is off, ignore state only updated when tracking

Amends 3310e13a17d2249a86fa533e350744c5593be54f. The explicit hovering state
is only updated when handling MouseMove events, and those are only
delivered when mouseTracking is set. Without mouseTracking set, the state
was always false, and QPushButton didn't set the MouseOver style flag.

Ignore the new state if mouse tracking is not set.

Task-number: QTBUG-87706
Change-Id: I2718fb23c206fd8dfd427edc987ff193ba1be8a0
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-10-26 17:15:56 +01:00
parent 6949bfaa92
commit fd8e6a203e

View File

@ -330,7 +330,7 @@ void QPushButton::initStyleOption(QStyleOptionButton *option) const
option->state |= QStyle::State_On;
if (!d->flat && !d->down)
option->state |= QStyle::State_Raised;
if (underMouse())
if (underMouse() && hasMouseTracking())
option->state.setFlag(QStyle::State_MouseOver, d->hovering);
option->text = d->text;
option->icon = d->icon;