1 | // Copyright (C) 2020 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QBUTTONGROUP_H |
5 | #define QBUTTONGROUP_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtCore/qobject.h> |
9 | |
10 | QT_REQUIRE_CONFIG(buttongroup); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QAbstractButton; |
15 | class QAbstractButtonPrivate; |
16 | class QButtonGroupPrivate; |
17 | |
18 | class Q_WIDGETS_EXPORT QButtonGroup : public QObject |
19 | { |
20 | Q_OBJECT |
21 | |
22 | Q_PROPERTY(bool exclusive READ exclusive WRITE setExclusive) |
23 | public: |
24 | explicit QButtonGroup(QObject *parent = nullptr); |
25 | ~QButtonGroup(); |
26 | |
27 | void setExclusive(bool); |
28 | bool exclusive() const; |
29 | |
30 | void addButton(QAbstractButton *, int id = -1); |
31 | void removeButton(QAbstractButton *); |
32 | |
33 | QList<QAbstractButton*> buttons() const; |
34 | |
35 | QAbstractButton * checkedButton() const; |
36 | // no setter on purpose! |
37 | |
38 | QAbstractButton *button(int id) const; |
39 | void setId(QAbstractButton *button, int id); |
40 | int id(QAbstractButton *button) const; |
41 | int checkedId() const; |
42 | |
43 | Q_SIGNALS: |
44 | void buttonClicked(QAbstractButton *); |
45 | void buttonPressed(QAbstractButton *); |
46 | void buttonReleased(QAbstractButton *); |
47 | void buttonToggled(QAbstractButton *, bool); |
48 | void idClicked(int); |
49 | void idPressed(int); |
50 | void idReleased(int); |
51 | void idToggled(int, bool); |
52 | |
53 | private: |
54 | Q_DISABLE_COPY(QButtonGroup) |
55 | Q_DECLARE_PRIVATE(QButtonGroup) |
56 | friend class QAbstractButton; |
57 | friend class QAbstractButtonPrivate; |
58 | }; |
59 | |
60 | QT_END_NAMESPACE |
61 | |
62 | #endif // QBUTTONGROUP_H |
63 |