From df5606ebd360d753b6261133254408aadbbb7f7f Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 4 Oct 2021 11:07:47 +0200 Subject: Make connectSingleShot() a tiny wrapper on Qt 6 Qt 6 has Qt::SingleShotConnection; connectSingleShot remains just for the sake of compatibility across Qt 5 and Qt 6. If you target Qt 6 only, feel free to use the Qt facility directly. --- lib/qt_connection_util.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/qt_connection_util.h b/lib/qt_connection_util.h index ffefb2a2..46294499 100644 --- a/lib/qt_connection_util.h +++ b/lib/qt_connection_util.h @@ -106,6 +106,11 @@ inline auto connectSingleShot(SenderT* sender, SignalT signal, ContextT* context, const FunctorT& slot, Qt::ConnectionType connType = Qt::AutoConnection) { +#if QT_VERSION_MAJOR >= 6 + return QObject::connect(sender, signal, context, slot, + Qt::ConnectionType(connType + | Qt::SingleShotConnection)); +#else return _impl::connectSingleShot( sender, signal, context, _impl::wrap_in_function(slot), connType); } @@ -125,6 +130,7 @@ inline auto connectSingleShot(SenderT* sender, SignalT signal, (receiver->*slot)(args...); }), connType); +#endif } /*! \brief A guard pointer that disconnects an interested object upon destruction -- cgit v1.2.3