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
qabstractbutton.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QABSTRACTBUTTON_H
6#define QABSTRACTBUTTON_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtGui/qicon.h>
10#if QT_CONFIG(shortcut)
11# include <QtGui/qkeysequence.h>
12#endif
13#include <QtWidgets/qwidget.h>
14
15QT_REQUIRE_CONFIG(abstractbutton);
16
17QT_BEGIN_NAMESPACE
18
19
20class QButtonGroup;
22
23class Q_WIDGETS_EXPORT QAbstractButton : public QWidget
24{
25 Q_OBJECT
26
27 Q_PROPERTY(QString text READ text WRITE setText)
28 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
29 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
30#ifndef QT_NO_SHORTCUT
31 Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
32#endif
33 Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
34 Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled USER true)
35 Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
36 Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive)
37 Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay)
38 Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval)
39 Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false)
40
41public:
42 explicit QAbstractButton(QWidget *parent = nullptr);
43 ~QAbstractButton();
44
45 void setText(const QString &text);
46 QString text() const;
47
48 void setIcon(const QIcon &icon);
49 QIcon icon() const;
50
51 QSize iconSize() const;
52
53#ifndef QT_NO_SHORTCUT
54 void setShortcut(const QKeySequence &key);
55 QKeySequence shortcut() const;
56#endif
57
58 void setCheckable(bool);
59 bool isCheckable() const;
60
61 bool isChecked() const;
62
63 void setDown(bool);
64 bool isDown() const;
65
66 void setAutoRepeat(bool);
67 bool autoRepeat() const;
68
69 void setAutoRepeatDelay(int);
70 int autoRepeatDelay() const;
71
72 void setAutoRepeatInterval(int);
73 int autoRepeatInterval() const;
74
75 void setAutoExclusive(bool);
76 bool autoExclusive() const;
77
78#if QT_CONFIG(buttongroup)
79 QButtonGroup *group() const;
80#endif
81
82public Q_SLOTS:
83 void setIconSize(const QSize &size);
84 void animateClick();
85 void click();
86 void toggle();
87 void setChecked(bool);
88
89Q_SIGNALS:
90 void pressed();
91 void released();
92 void clicked(bool checked = false);
93 void toggled(bool checked);
94
95protected:
96 void paintEvent(QPaintEvent *e) override = 0;
97 virtual bool hitButton(const QPoint &pos) const;
98 virtual void checkStateSet();
99 virtual void nextCheckState();
100
101 bool event(QEvent *e) override;
102 void keyPressEvent(QKeyEvent *e) override;
103 void keyReleaseEvent(QKeyEvent *e) override;
104 void mousePressEvent(QMouseEvent *e) override;
105 void mouseReleaseEvent(QMouseEvent *e) override;
106 void mouseMoveEvent(QMouseEvent *e) override;
107 void focusInEvent(QFocusEvent *e) override;
108 void focusOutEvent(QFocusEvent *e) override;
109 void changeEvent(QEvent *e) override;
110 void timerEvent(QTimerEvent *e) override;
111
112
113protected:
114 QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = nullptr);
115
116private:
117 Q_DECLARE_PRIVATE(QAbstractButton)
118 Q_DISABLE_COPY(QAbstractButton)
119 friend class QButtonGroup;
120};
121
122QT_END_NAMESPACE
123
124#endif // QABSTRACTBUTTON_H
QList< QAbstractButton * > queryButtonList() const
QSizePolicy::ControlType controlType
QAbstractButton * queryCheckedButton() const
void emitToggled(bool checked)
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
friend class QWidget
Definition qpainter.h:431
#define AUTO_REPEAT_INTERVAL
#define AUTO_REPEAT_DELAY
Q_WIDGETS_EXPORT bool qt_tab_all_widgets()