Skip to content

Commit

Permalink
Merge pull request #41 from twxs/feature/fix_qt6_build
Browse files Browse the repository at this point in the history
With Qt6 `tabIndex` is a member of `QStyleOptionTab`
  • Loading branch information
oclero authored Oct 9, 2023
2 parents ba09322 + 7c52da8 commit ad4c5d4
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/src/utils/StyleUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ bool shouldNotHaveWheelEvents(const QWidget* w) {
|| qobject_cast<const QAbstractSpinBox*>(w);
}

int getTabIndex(const QStyleOptionTab* optTab, const QWidget* parentWidget) {
if (const auto* optTabV4 = qstyleoption_cast<const QStyleOptionTabV4*>(optTab)) {
return optTabV4->tabIndex;
}

if (const auto* tabBar = qobject_cast<const QTabBar*>(parentWidget)) {
return tabBar->tabAt(optTab->rect.topLeft());
}

return -1;
int getTabIndex(const QStyleOptionTab* optTab, [[maybe_unused]]const QWidget* parentWidget) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return optTab->tabIndex;
#else
if (const auto* optTabV4 = qstyleoption_cast<const QStyleOptionTabV4*>(optTab)) {
return optTabV4->tabIndex;
}

if (const auto* tabBar = qobject_cast<const QTabBar*>(parentWidget)) {
return tabBar->tabAt(optTab->rect.topLeft());
}

return -1;
#endif
}

int getTabCount(const QWidget* parentWidget) {
Expand Down

0 comments on commit ad4c5d4

Please sign in to comment.