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
qtoolbar.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 QDYNAMICTOOLBAR_H
5#define QDYNAMICTOOLBAR_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtGui/qaction.h>
9#include <QtWidgets/qwidget.h>
10
12
14
15class QToolBarPrivate;
16
17class QAction;
18class QIcon;
19class QMainWindow;
20class QStyleOptionToolBar;
21
22class Q_WIDGETS_EXPORT QToolBar : public QWidget
23{
25
26 Q_PROPERTY(bool movable READ isMovable WRITE setMovable NOTIFY movableChanged)
27 Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas
28 NOTIFY allowedAreasChanged)
29 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation
30 NOTIFY orientationChanged)
31 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
32 Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle
33 NOTIFY toolButtonStyleChanged)
34 Q_PROPERTY(bool floating READ isFloating)
35 Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable)
36
37public:
38 explicit QToolBar(const QString &title, QWidget *parent = nullptr);
39 explicit QToolBar(QWidget *parent = nullptr);
40 ~QToolBar();
41
42 void setMovable(bool movable);
43 bool isMovable() const;
44
45 void setAllowedAreas(Qt::ToolBarAreas areas);
46 Qt::ToolBarAreas allowedAreas() const;
47
48 inline bool isAreaAllowed(Qt::ToolBarArea area) const
49 { return (allowedAreas() & area) == area; }
50
51 void setOrientation(Qt::Orientation orientation);
52 Qt::Orientation orientation() const;
53
54 void clear();
55
57#if QT_WIDGETS_REMOVED_SINCE(6, 3)
58 QAction *addAction(const QString &text);
59 QAction *addAction(const QIcon &icon, const QString &text);
60 QAction *addAction(const QString &text, const QObject *receiver, const char* member);
61 QAction *addAction(const QIcon &icon, const QString &text,
62 const QObject *receiver, const char* member);
63#endif
64
65 QAction *addSeparator();
66 QAction *insertSeparator(QAction *before);
67
69 QAction *insertWidget(QAction *before, QWidget *widget);
70
71 QRect actionGeometry(QAction *action) const;
72 QAction *actionAt(const QPoint &p) const;
73 inline QAction *actionAt(int x, int y) const;
74
75 QAction *toggleViewAction() const;
76
77 QSize iconSize() const;
78 Qt::ToolButtonStyle toolButtonStyle() const;
79
80 QWidget *widgetForAction(QAction *action) const;
81
82 bool isFloatable() const;
83 void setFloatable(bool floatable);
84 bool isFloating() const;
85
86public Q_SLOTS:
87 void setIconSize(const QSize &iconSize);
88 void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
89
91 void actionTriggered(QAction *action);
92 void movableChanged(bool movable);
93 void allowedAreasChanged(Qt::ToolBarAreas allowedAreas);
97 void topLevelChanged(bool topLevel);
98 void visibilityChanged(bool visible);
99
100protected:
101 void actionEvent(QActionEvent *event) override;
102 void changeEvent(QEvent *event) override;
103 void paintEvent(QPaintEvent *event) override;
104 bool event(QEvent *event) override;
105 virtual void initStyleOption(QStyleOptionToolBar *option) const;
106
107
108private:
109 Q_DECLARE_PRIVATE(QToolBar)
110 Q_DISABLE_COPY(QToolBar)
111 Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
112 Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &))
113 Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle))
114
115 friend class QMainWindow;
116 friend class QMainWindowLayout;
117 friend class QToolBarLayout;
118 friend class QToolBarAreaLayout;
119};
120
121inline QAction *QToolBar::actionAt(int ax, int ay) const
122{ return actionAt(QPoint(ax, ay)); }
123
125
126#endif // QDYNAMICTOOLBAR_H
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 QtCore
Definition qcoreevent.h:45
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QMainWindow class provides a main application window.
Definition qmainwindow.h:25
\inmodule QtCore
Definition qobject.h:103
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QToolBar class provides a movable panel that contains a set of controls.
Definition qtoolbar.h:23
void topLevelChanged(bool topLevel)
void visibilityChanged(bool visible)
void actionTriggered(QAction *action)
This signal is emitted when an action in this toolbar is triggered.
void orientationChanged(Qt::Orientation orientation)
This signal is emitted when the orientation of the toolbar changes.
void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle)
This signal is emitted when the tool button style is changed.
QAction * actionAt(const QPoint &p) const
Returns the action at point p.
Definition qtoolbar.cpp:842
void movableChanged(bool movable)
This signal is emitted when the toolbar becomes movable or fixed.
void allowedAreasChanged(Qt::ToolBarAreas allowedAreas)
This signal is emitted when the collection of allowed areas for the toolbar is changed.
void iconSizeChanged(const QSize &iconSize)
This signal is emitted when the icon size is changed.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition qwidget.cpp:3117
QOpenGLWidget * widget
[1]
b clear()
QString text
opt iconSize
Combined button and popup list for selecting options.
Definition qcompare.h:63
Orientation
Definition qnamespace.h:98
ToolButtonStyle
static int area(const QSize &s)
Definition qicon.cpp:153
GLint GLint GLint GLint GLint x
[0]
GLint y
struct _cl_event * event
GLfloat GLfloat p
[1]
GLuint GLenum option
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
#define explicit
QString title
[35]
gridLayout addWidget(nameLabel, 0, 0)