path: root/src/widgets/kernel/qactiongroup.h
diff options
authorFriedemann Kleint <>2019-06-19 13:00:11 +0200
committerFriedemann Kleint <>2019-10-31 10:14:55 +0100
commitcff492fed1d98f45c4c1f4011f1451120c0d1c23 (patch)
treee13e62fc77ea4e42c0835cd444e5811f7e054875 /src/widgets/kernel/qactiongroup.h
parentd273076b4474bb473d90e996960c4c773745761a (diff)
Extract QGuiAction(Group) from QAction(Group) into QtGui
Simply moving QAction to QtGui was not deemed possible since it operates on a set of controls of some kind. The approach to extract a base class was taken instead, named QGuiAction following the QGuiApplication scheme. QAction remains in widgets, but changes base class. For QActionGroup, the functions addAction(text/icon), which create an action, cannot be implemented in QtGui, hence a base class is needed, too (unless they are deprecated and removed). - Extract base classes providing functionality not based on QtWidgets, using virtuals in QGuiActionPrivate to provide customization points - Change QActionEvent to take QGuiAction, removing the need to forward declare QAction in QtGui [ChangeLog][QtGui] Added QGuiAction(Group) and made the equivalent existing classes in Qt Widgets derive from them. This provides basic functionality for implementing actions in QML. Task-number: QTBUG-69478 Change-Id: Ic490a5e3470939ee8af612d46ff41d4c8c91fbdf Reviewed-by: Lars Knoll <> Reviewed-by: Mitch Curtis <> Reviewed-by: Oliver Wolff <> Reviewed-by: Allan Sandfeld Jensen <>
Diffstat (limited to 'src/widgets/kernel/qactiongroup.h')
1 files changed, 6 insertions, 31 deletions
diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h
index 90f488bedb..6ec2fc09ef 100644
--- a/src/widgets/kernel/qactiongroup.h
+++ b/src/widgets/kernel/qactiongroup.h
@@ -41,6 +41,7 @@
#include <QtWidgets/qtwidgetsglobal.h>
+#include <QtGui/qguiactiongroup.h>
#include <QtWidgets/qaction.h>
@@ -50,45 +51,22 @@ QT_BEGIN_NAMESPACE
class QActionGroupPrivate;
-class Q_WIDGETS_EXPORT QActionGroup : public QObject
+class Q_WIDGETS_EXPORT QActionGroup : public QGuiActionGroup
- Q_PROPERTY(QActionGroup::ExclusionPolicy exclusionPolicy READ exclusionPolicy WRITE setExclusionPolicy)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
- enum class ExclusionPolicy {
- None,
- Exclusive,
- ExclusiveOptional
- };
- Q_ENUM(ExclusionPolicy)
explicit QActionGroup(QObject* parent);
- QAction *addAction(QAction* a);
- QAction *addAction(const QString &text);
- QAction *addAction(const QIcon &icon, const QString &text);
- void removeAction(QAction *a);
- QList<QAction*> actions() const;
QAction *checkedAction() const;
- bool isExclusive() const;
- bool isEnabled() const;
- bool isVisible() const;
- ExclusionPolicy exclusionPolicy() const;
+ QAction *addAction(QAction *a);
+ QAction *addAction(const QString &text);
+ QAction *addAction(const QIcon &icon, const QString &text);
-public Q_SLOTS:
- void setEnabled(bool);
- inline void setDisabled(bool b) { setEnabled(!b); }
- void setVisible(bool);
- void setExclusive(bool);
- void setExclusionPolicy(ExclusionPolicy policy);
+ QList<QAction*> actions() const;
void triggered(QAction *);
@@ -96,9 +74,6 @@ Q_SIGNALS:
- Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
- Q_PRIVATE_SLOT(d_func(), void _q_actionChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
#endif // QT_NO_ACTION