1 | // Copyright (C) 2016 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 QCHECKBOX_H |
5 | #define QCHECKBOX_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qabstractbutton.h> |
9 | |
10 | QT_REQUIRE_CONFIG(checkbox); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | |
15 | class QCheckBoxPrivate; |
16 | class QStyleOptionButton; |
17 | |
18 | class Q_WIDGETS_EXPORT QCheckBox : public QAbstractButton |
19 | { |
20 | Q_OBJECT |
21 | |
22 | Q_PROPERTY(bool tristate READ isTristate WRITE setTristate) |
23 | |
24 | public: |
25 | explicit QCheckBox(QWidget *parent = nullptr); |
26 | explicit QCheckBox(const QString &text, QWidget *parent = nullptr); |
27 | ~QCheckBox(); |
28 | |
29 | QSize sizeHint() const override; |
30 | QSize minimumSizeHint() const override; |
31 | |
32 | void setTristate(bool y = true); |
33 | bool isTristate() const; |
34 | |
35 | Qt::CheckState checkState() const; |
36 | void setCheckState(Qt::CheckState state); |
37 | |
38 | Q_SIGNALS: |
39 | #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) |
40 | void stateChanged(int); |
41 | #else |
42 | void stateChanged(Qt::CheckState); |
43 | #endif |
44 | |
45 | protected: |
46 | bool event(QEvent *e) override; |
47 | bool hitButton(const QPoint &pos) const override; |
48 | void checkStateSet() override; |
49 | void nextCheckState() override; |
50 | void paintEvent(QPaintEvent *) override; |
51 | void mouseMoveEvent(QMouseEvent *) override; |
52 | virtual void initStyleOption(QStyleOptionButton *option) const; |
53 | |
54 | |
55 | private: |
56 | Q_DECLARE_PRIVATE(QCheckBox) |
57 | Q_DISABLE_COPY(QCheckBox) |
58 | friend class QAccessibleButton; |
59 | }; |
60 | |
61 | QT_END_NAMESPACE |
62 | |
63 | #endif // QCHECKBOX_H |
64 | |