summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWang Chuan <ouchuanm@outlook.com>2020-06-26 23:43:26 +0800
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-02 04:17:52 +0200
commitc513b1214e38829e9bc23bb2ef948f5c388071a7 (patch)
treea03bbb9419559308153b16bd85deefb3f73f6d50 /src
parent843b40328610c5e61bd7cada03c2046ece788b02 (diff)
QTabBar: make sure the tab is repainted after releasing mouse
The tab has to be repainted even f the mouse release event happened outside the tab bar, otherwise it will look like the tab is still pressed. As a drive-by, replace the repaint() call with update(); there is no need for synchronous painting in an event handler. Pick-to: 5.15 Fixes: QTBUG-81637 Change-Id: Ia55182be906511ac3b462f00add8a621c6c05fc3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qtabbar.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index a3b926e549..a3914dccfe 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -2304,6 +2304,8 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
d->dragStartPosition = QPoint();
}
+ // mouse release event might happen outside the tab, so keep the pressed index
+ int oldPressedIndex = d->pressedIndex;
int i = d->indexAtPos(event->position().toPoint()) == d->pressedIndex ? d->pressedIndex : -1;
d->pressedIndex = -1;
QStyleOptionTabBarBase optTabBase;
@@ -2313,8 +2315,8 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
(style()->styleHint(QStyle::SH_TabBar_SelectMouseType, &optTabBase, this) == QEvent::MouseButtonRelease);
if (selectOnRelease)
setCurrentIndex(i);
- if (!selectOnRelease || !d->validIndex(i) || d->currentIndex == i)
- repaint(tabRect(i));
+ if (d->validIndex(oldPressedIndex))
+ update(tabRect(oldPressedIndex));
}
/*!\reimp