Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qpushbutton.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
4#ifndef QPUSHBUTTON_H
5#define QPUSHBUTTON_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qabstractbutton.h>
9
11
13
14
16class QMenu;
18
19class Q_WIDGETS_EXPORT QPushButton : public QAbstractButton
20{
22
23 Q_PROPERTY(bool autoDefault READ autoDefault WRITE setAutoDefault)
24 Q_PROPERTY(bool default READ isDefault WRITE setDefault)
25 Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
26
27public:
28 explicit QPushButton(QWidget *parent = nullptr);
29 explicit QPushButton(const QString &text, QWidget *parent = nullptr);
30 QPushButton(const QIcon& icon, const QString &text, QWidget *parent = nullptr);
32
33 QSize sizeHint() const override;
34 QSize minimumSizeHint() const override;
35
36 bool autoDefault() const;
37 void setAutoDefault(bool);
38 bool isDefault() const;
39 void setDefault(bool);
40
41#if QT_CONFIG(menu)
42 void setMenu(QMenu* menu);
43 QMenu* menu() const;
44#endif
45
46 void setFlat(bool);
47 bool isFlat() const;
48
49public Q_SLOTS:
50#if QT_CONFIG(menu)
51 void showMenu();
52#endif
53
54protected:
55 bool event(QEvent *e) override;
56 void paintEvent(QPaintEvent *) override;
57 void keyPressEvent(QKeyEvent *) override;
58 void focusInEvent(QFocusEvent *) override;
59 void focusOutEvent(QFocusEvent *) override;
60 void mouseMoveEvent(QMouseEvent *) override;
61 virtual void initStyleOption(QStyleOptionButton *option) const;
62 bool hitButton(const QPoint &pos) const override;
64
65public:
66
67private:
68 Q_DISABLE_COPY(QPushButton)
69 Q_DECLARE_PRIVATE(QPushButton)
70#if QT_CONFIG(menu)
71 Q_PRIVATE_SLOT(d_func(), void _q_popupPressed())
72#endif
73};
74
76
77#endif // QPUSHBUTTON_H
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
void mouseMoveEvent(QMouseEvent *e) override
\reimp
void focusInEvent(QFocusEvent *e) override
\reimp
void paintEvent(QPaintEvent *e) override=0
\reimp
void keyPressEvent(QKeyEvent *e) override
\reimp
void focusOutEvent(QFocusEvent *e) override
\reimp
virtual bool hitButton(const QPoint &pos) const
Returns true if pos is inside the clickable button rectangle; otherwise returns false.
\inmodule QtCore
Definition qcoreevent.h:45
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QKeyEvent class describes a key event.
Definition qevent.h:423
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
\inmodule QtGui
Definition qevent.h:195
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:485
\inmodule QtCore\reentrant
Definition qpoint.h:23
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\variable QStyleOptionHeaderV2::textElideMode
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QSize minimumSizeHint
the recommended minimum size for the widget
Definition qwidget.h:149
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
QString text
double e
Combined button and popup list for selecting options.
struct _cl_event * event
GLuint GLenum option
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_PRIVATE_SLOT(d, signature)
QMenu menu
[5]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent