From d5b3ddffae0a878618bb2637539054dc2e397706 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 9 Nov 2018 15:54:42 +0100 Subject: QMacStyle: account for QStyleSheetStyle using QTabBar directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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(w->parentWidget())) { + QTabBar *tabBar = qobject_cast(w->parentWidget()); + if (!tabBar) { + // QStyleSheetStyle instead of CloseButton (which has + // a QTabBar as a parent widget) uses the QTabBar itself: + tabBar = qobject_cast(const_cast(w)); + } + if (tabBar) { const bool documentMode = tabBar->documentMode(); const QTabBarPrivate *tabBarPrivate = static_cast(QObjectPrivate::get(tabBar)); const int hoveredTabIndex = tabBarPrivate->hoveredTabIndex(); -- cgit v1.2.3