Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtoolbutton.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 QTOOLBUTTON_H
5#define QTOOLBUTTON_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8
9#include <QtWidgets/qabstractbutton.h>
10
12
14
16class QMenu;
18
19class Q_WIDGETS_EXPORT QToolButton : public QAbstractButton
20{
23#if QT_CONFIG(menu)
24 Q_PROPERTY(ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode)
25#endif
26 Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
27 Q_PROPERTY(bool autoRaise READ autoRaise WRITE setAutoRaise)
28 Q_PROPERTY(Qt::ArrowType arrowType READ arrowType WRITE setArrowType)
29
30public:
34 InstantPopup
35 };
36 Q_ENUM(ToolButtonPopupMode)
37
38 explicit QToolButton(QWidget *parent = nullptr);
40
41 QSize sizeHint() const override;
42 QSize minimumSizeHint() const override;
43
44 Qt::ToolButtonStyle toolButtonStyle() const;
45
46 Qt::ArrowType arrowType() const;
47 void setArrowType(Qt::ArrowType type);
48
49#if QT_CONFIG(menu)
50 void setMenu(QMenu* menu);
51 QMenu* menu() const;
52
53 void setPopupMode(ToolButtonPopupMode mode);
54 ToolButtonPopupMode popupMode() const;
55#endif
56
57 QAction *defaultAction() const;
58
59 void setAutoRaise(bool enable);
60 bool autoRaise() const;
61
62public Q_SLOTS:
63#if QT_CONFIG(menu)
64 void showMenu();
65#endif
66 void setToolButtonStyle(Qt::ToolButtonStyle style);
67 void setDefaultAction(QAction *);
68
71
72protected:
73 bool event(QEvent *e) override;
74 void mousePressEvent(QMouseEvent *) override;
75 void mouseReleaseEvent(QMouseEvent *) override;
76 void paintEvent(QPaintEvent *) override;
77 void actionEvent(QActionEvent *) override;
78
79 void enterEvent(QEnterEvent *) override;
80 void leaveEvent(QEvent *) override;
81 void timerEvent(QTimerEvent *) override;
82 void changeEvent(QEvent *) override;
83
84 bool hitButton(const QPoint &pos) const override;
85 void checkStateSet() override;
86 void nextCheckState() override;
87 virtual void initStyleOption(QStyleOptionToolButton *option) const;
88
89private:
90 Q_DISABLE_COPY(QToolButton)
91 Q_DECLARE_PRIVATE(QToolButton)
92#if QT_CONFIG(menu)
93 Q_PRIVATE_SLOT(d_func(), void _q_buttonPressed())
94 Q_PRIVATE_SLOT(d_func(), void _q_buttonReleased())
95 Q_PRIVATE_SLOT(d_func(), void _q_updateButtonDown())
96 Q_PRIVATE_SLOT(d_func(), void _q_menuTriggered(QAction*))
97#endif
98 Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
99
100};
101
103
104#endif // QTOOLBUTTON_H
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
void mousePressEvent(QMouseEvent *e) override
\reimp
void mouseReleaseEvent(QMouseEvent *e) override
\reimp
void paintEvent(QPaintEvent *e) override=0
\reimp
void timerEvent(QTimerEvent *e) override
\reimp
void changeEvent(QEvent *e) override
\reimp
virtual void checkStateSet()
This virtual handler is called when setChecked() is used, unless it is called from within nextCheckSt...
virtual bool hitButton(const QPoint &pos) const
Returns true if pos is inside the clickable button rectangle; otherwise returns false.
virtual void nextCheckState()
This virtual handler is called when a button is clicked.
The QActionEvent class provides an event that is generated when a QAction is added,...
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
\inmodule QtGui
Definition qevent.h:164
\inmodule QtCore
Definition qcoreevent.h:45
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
\inmodule QtCore
Definition qsize.h:25
\variable QStyleOptionDockWidget::title
\inmodule QtCore
Definition qcoreevent.h:359
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition qtoolbutton.h:20
void triggered(QAction *)
This signal is emitted when the given action is triggered.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
virtual void leaveEvent(QEvent *event)
This event handler can be reimplemented in a subclass to receive widget leave events which are passed...
Definition qwidget.cpp:9777
virtual void actionEvent(QActionEvent *event)
This event handler is called with the given event whenever the widget's actions are changed.
Definition qwidget.cpp:9881
QSize minimumSizeHint
the recommended minimum size for the widget
Definition qwidget.h:149
virtual void enterEvent(QEnterEvent *event)
This event handler can be reimplemented in a subclass to receive widget enter events which are passed...
Definition qwidget.cpp:9761
QSize sizeHint
the recommended size for the widget
Definition qwidget.h:148
double e
Combined button and popup list for selecting options.
ArrowType
ToolButtonStyle
GLenum mode
GLenum type
GLboolean enable
struct _cl_event * event
GLuint GLenum option
#define QT_REQUIRE_CONFIG(feature)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_ENUMS(x)
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
QMenu menu
[5]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent