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 <richard.gustavsen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ade3bb1c5224a9155a2a2f965fa70740aa9ec8a7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2025-01-14 10:13:19 +01:00 committed by Qt Cherry-pick Bot
parent 37c389c779
commit c82464ea75

View File

@ -71,6 +71,7 @@ public:
const QObject *context2, FunctorAmbiguous functorAmbiguous,
Qt::ShortcutContext shortcutContext = Qt::WindowShortcut);
#else
#ifndef QT_NO_CONTEXTLESS_CONNECT
template<typename Func1>
QShortcut(const QKeySequence &key, QObject *parent,
Func1 slot1,
@ -79,6 +80,7 @@ public:
{
connect(this, &QShortcut::activated, std::move(slot1));
}
#endif
template<class Obj1, typename Func1>
QShortcut(const QKeySequence &key, QObject *parent,
const Obj1 *object1, Func1 slot1,