diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2018-11-09 15:54:42 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-11-21 05:35:21 +0000 |
commit | d5b3ddffae0a878618bb2637539054dc2e397706 (patch) | |
tree | 6c34f0c2ea3f22d1c9cf62f855b7e13b27d2f434 /src/plugins/styles | |
parent | aa75697b63627d5c1ff90aa967ba58bbad7cae18 (diff) |
QMacStyle: account for QStyleSheetStyle using QTabBar directly
in this case w->parentWidget() is not QTabBar, but QTabWidget and we
never draw PE_IndicatorTabClose control (before the recent major
re-write in qmacstyle we never tested the actual type).
Task-number: QTBUG-61092
Change-Id: I87c4813258cc2b483b2ef278c4a2f8796973af1c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/styles')
-rw-r--r-- | src/plugins/styles/mac/qmacstyle_mac.mm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 1fd3420899..b84448d5e2 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3229,7 +3229,13 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai break; case PE_IndicatorTabClose: { // Make close button visible only on the hovered tab. - if (QTabBar *tabBar = qobject_cast<QTabBar*>(w->parentWidget())) { + QTabBar *tabBar = qobject_cast<QTabBar*>(w->parentWidget()); + if (!tabBar) { + // QStyleSheetStyle instead of CloseButton (which has + // a QTabBar as a parent widget) uses the QTabBar itself: + tabBar = qobject_cast<QTabBar *>(const_cast<QWidget*>(w)); + } + if (tabBar) { const bool documentMode = tabBar->documentMode(); const QTabBarPrivate *tabBarPrivate = static_cast<QTabBarPrivate *>(QObjectPrivate::get(tabBar)); const int hoveredTabIndex = tabBarPrivate->hoveredTabIndex(); |