From c82464ea754e0345859abb54f31b636541669f0b Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 14 Jan 2025 10:13:19 +0100 Subject: [PATCH] QShortcut: fix build under QT_NO_CONTEXTLESS_CONNECT QShortcut has a constructor that takes a _parent_ object and a function to invoke, and it will internally connect its activated() signal to that function. This connection will not provide a context object (the parent is not used to this purpose). Given it's not clear what the context should be if any (the parent? `this`?), I'm not at ease at just supplying "something" as the context. Instead, hide the constructor if we're under QT_NO_CONTEXTLESS_CONNECT. There's another constructor where the caller can supply a context. Change-Id: I21befcc86eeb07e65eadee1222757ecc5bab1d2c Pick-to: 6.8 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Volker Hilsheimer (cherry picked from commit ade3bb1c5224a9155a2a2f965fa70740aa9ec8a7) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qshortcut.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qshortcut.h b/src/gui/kernel/qshortcut.h index 00b9168bea8..9abd8a06383 100644 --- a/src/gui/kernel/qshortcut.h +++ b/src/gui/kernel/qshortcut.h @@ -71,6 +71,7 @@ public: const QObject *context2, FunctorAmbiguous functorAmbiguous, Qt::ShortcutContext shortcutContext = Qt::WindowShortcut); #else +#ifndef QT_NO_CONTEXTLESS_CONNECT template QShortcut(const QKeySequence &key, QObject *parent, Func1 slot1, @@ -79,6 +80,7 @@ public: { connect(this, &QShortcut::activated, std::move(slot1)); } +#endif template QShortcut(const QKeySequence &key, QObject *parent, const Obj1 *object1, Func1 slot1,