Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qbuttongroup.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QBUTTONGROUP_H
6#define QBUTTONGROUP_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtCore/qobject.h>
10
12
13QT_BEGIN_NAMESPACE
14
15class QAbstractButton;
17class QButtonGroupPrivate;
18
19class Q_WIDGETS_EXPORT QButtonGroup : public QObject
20{
21 Q_OBJECT
22
23 Q_PROPERTY(bool exclusive READ exclusive WRITE setExclusive)
24public:
25 explicit QButtonGroup(QObject *parent = nullptr);
26 ~QButtonGroup();
27
28 void setExclusive(bool);
29 bool exclusive() const;
30
31 void addButton(QAbstractButton *, int id = -1);
32 void removeButton(QAbstractButton *);
33
34 QList<QAbstractButton*> buttons() const;
35
36 QAbstractButton * checkedButton() const;
37 // no setter on purpose!
38
39 QAbstractButton *button(int id) const;
40 void setId(QAbstractButton *button, int id);
41 int id(QAbstractButton *button) const;
42 int checkedId() const;
43
44Q_SIGNALS:
45 void buttonClicked(QAbstractButton *);
46 void buttonPressed(QAbstractButton *);
47 void buttonReleased(QAbstractButton *);
48 void buttonToggled(QAbstractButton *, bool);
49 void idClicked(int);
50 void idPressed(int);
51 void idReleased(int);
52 void idToggled(int, bool);
53
54private:
55 Q_DISABLE_COPY(QButtonGroup)
56 Q_DECLARE_PRIVATE(QButtonGroup)
57 friend class QAbstractButton;
58 friend class QAbstractButtonPrivate;
59};
60
61QT_END_NAMESPACE
62
63#endif // QBUTTONGROUP_H
The QButtonGroup class provides a container to organize groups of button widgets.
QT_REQUIRE_CONFIG(buttongroup)