From 7a39746fa36c0178824ae6f670e031eff3a2499c Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Mon, 6 Jan 2025 13:39:25 +0100 Subject: [PATCH] Gui: Fix crash on scrolling workbench tab bar in Qt 5.15.3 --- src/Gui/WorkbenchSelector.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Gui/WorkbenchSelector.h b/src/Gui/WorkbenchSelector.h index c949ee5b50..d5955cfb45 100644 --- a/src/Gui/WorkbenchSelector.h +++ b/src/Gui/WorkbenchSelector.h @@ -110,14 +110,13 @@ class GuiExport WorkbenchTabWidget : public QWidget { // Qt does not expose any way to programmatically control scroll of QTabBar hence // we need to use a bit hacky solution of simulating clicks on the scroll buttons + const auto buttonToClickName = wheelEvent->angleDelta().y() < 0 + ? QStringLiteral("ScrollLeftButton") + : QStringLiteral("ScrollRightButton"); - auto left = findChild(QString::fromUtf8("ScrollLeftButton")); - auto right = findChild(QString::fromUtf8("ScrollRightButton")); - - if (wheelEvent->angleDelta().y() > 0) { - right->click(); - } else { - left->click(); + // Qt introduces named buttons in Qt 6.3 and 5.15.6, before that they are not available + if (const auto button = findChild(buttonToClickName)) { + button->click(); } }