diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index e6581e212..ccea1e257 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -1210,17 +1210,19 @@ bool TabBarHelper::event(QEvent* ev) // Hack to get dragOffset from QTabBar internals int TabBarHelper::dragOffset(QStyleOptionTab *option, int tabIndex) const { - QStyle::SubElement element = QStyle::SE_TabBarTabLeftButton; + QRect rect; QWidget *button = tabButton(tabIndex, QTabBar::LeftSide); - if (!button) { - element = QStyle::SE_TabBarTabRightButton; - button = tabButton(tabIndex, QTabBar::RightSide); + if (button) { + rect = style()->subElementRect(QStyle::SE_TabBarTabLeftButton, option, this); } - if (!button) { + if (!rect.isValid()) { + button = tabButton(tabIndex, QTabBar::RightSide); + rect = style()->subElementRect(QStyle::SE_TabBarTabRightButton, option, this); + } + if (!button || !rect.isValid()) { return 0; } - const QPoint p = style()->subElementRect(element, option, this).topLeft(); - return button->pos().x() - p.x(); + return button->pos().x() - rect.topLeft().x(); } // Taken from qtabbar.cpp