From 971b8413f27f6e317e9e37f518fcc1e6b9eed978 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 9 Mar 2015 14:29:05 +0100 Subject: QAbstractButton: emit released on focus out or disable When pressing a button with the mouse and then moving the focus away, the internal and visual state of the button would get updated, but the released signal would not be emitted. The same goes for disabling the button, although in 99% of the cases, disabling the button will also move the focus, so the first case already takes care of emitting the signal. Task-number: QTBUG-42775 Change-Id: Ib6ba8e0a75f0349b66d1e799b02bd8498db85022 Reviewed-by: Gabriel de Dietrich --- src/widgets/widgets/qabstractbutton.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 965278265a..e413b3b87a 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -1293,8 +1293,10 @@ void QAbstractButton::focusInEvent(QFocusEvent *e) void QAbstractButton::focusOutEvent(QFocusEvent *e) { Q_D(QAbstractButton); - if (e->reason() != Qt::PopupFocusReason) + if (e->reason() != Qt::PopupFocusReason && d->down) { d->down = false; + d->emitReleased(); + } QWidget::focusOutEvent(e); } @@ -1304,8 +1306,10 @@ void QAbstractButton::changeEvent(QEvent *e) Q_D(QAbstractButton); switch (e->type()) { case QEvent::EnabledChange: - if (!isEnabled()) - setDown(false); + if (!isEnabled() && d->down) { + d->down = false; + d->emitReleased(); + } break; default: d->sizeHint = QSize(); -- cgit v1.2.3