summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmenubar.h
diff options
context:
space:
mode:
authorAnton Kudryavtsev <anton.kudryavtsev@corp.mail.ru>2018-01-02 16:57:39 +0300
committerAnton Kudryavtsev <antkudr@mail.ru>2018-01-06 18:48:54 +0000
commit79d3351855ea055bed0b5b752a4a6fed51a27f9b (patch)
treeb267a927fa48311e1a3373e095b9dd0ba4abbba3 /src/widgets/widgets/qmenubar.h
parentf99d2b21b8fc867f0ed21dcbfa47865ad013db97 (diff)
QMenuBar: Add overloads of addAction() using Qt 5 signals and slots
[ChangeLog][QtWidgets][QMenuBar] Add overloads of addAction() using Qt 5 signals and slots Change-Id: Ief21974213b80111f0ca87df490eb72dd6b9c9b9 Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmenubar.h')
-rw-r--r--src/widgets/widgets/qmenubar.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h
index 4f8e3b8d53..2f071e7e3b 100644
--- a/src/widgets/widgets/qmenubar.h
+++ b/src/widgets/widgets/qmenubar.h
@@ -67,6 +67,32 @@ public:
QAction *addAction(const QString &text);
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
+#ifdef Q_QDOC
+ template<typename Obj, typename PointerToMemberFunctionOrFunctor>
+ QAction *addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method);
+ template<typename Functor>
+ QAction *addAction(const QString &text, Functor functor);
+#else
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<typename Obj, typename Func1>
+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
+ addAction(const QString &text, const Obj *object, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, object, std::move(slot));
+ return result;
+ }
+ // addAction(QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QString &text, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, std::move(slot));
+ return result;
+ }
+#endif // !Q_QDOC
+
QAction *addMenu(QMenu *menu);
QMenu *addMenu(const QString &title);
QMenu *addMenu(const QIcon &icon, const QString &title);