Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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:
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};
93
95
96#endif // QTOOLBUTTON_H
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
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:165
\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:196
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore
Definition qsize.h:25
\variable QStyleOptionDockWidget::title
\inmodule QtCore
Definition qcoreevent.h:366
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
Combined button and popup list for selecting options.
Definition qcompare.h:63
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_SIGNALS
QMenu menu
[5]