Qt 4.8
qtoolbar.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDYNAMICTOOLBAR_H
43 #define QDYNAMICTOOLBAR_H
44 
45 #include <QtGui/qwidget.h>
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 #ifndef QT_NO_TOOLBAR
54 
55 class QToolBarPrivate;
56 
57 class QAction;
58 class QIcon;
59 class QMainWindow;
61 
63 {
64  Q_OBJECT
65 
66  bool movable;) != 0)
67  NOTIFY movableChanged)
68  Qt::ToolBarAreas allowedAreas;) != 0)
69  NOTIFY allowedAreasChanged)
70  Qt::Orientation orientation;) == 0)
71  NOTIFY orientationChanged)
72  QSize iconSize;
74  bool floating;
75  bool floatable;
76 
77 public:
78  explicit QToolBar(const QString &title, QWidget *parent = 0);
79  explicit QToolBar(QWidget *parent = 0);
80  ~QToolBar();
81 
82  void setMovable(bool movable);
83  bool isMovable() const;
84 
85  void setAllowedAreas(Qt::ToolBarAreas areas);
86  Qt::ToolBarAreas allowedAreas() const;
87 
88  inline bool isAreaAllowed(Qt::ToolBarArea area) const
89  { return (allowedAreas() & area) == area; }
90 
91  void setOrientation(Qt::Orientation orientation);
92  Qt::Orientation orientation() const;
93 
94  void clear();
95 
96 #ifdef Q_NO_USING_KEYWORD
97  inline void addAction(QAction *action)
98  { QWidget::addAction(action); }
99 #else
100  using QWidget::addAction;
101 #endif
102 
103  QAction *addAction(const QString &text);
104  QAction *addAction(const QIcon &icon, const QString &text);
105  QAction *addAction(const QString &text, const QObject *receiver, const char* member);
106  QAction *addAction(const QIcon &icon, const QString &text,
107  const QObject *receiver, const char* member);
108 
109  QAction *addSeparator();
110  QAction *insertSeparator(QAction *before);
111 
112  QAction *addWidget(QWidget *widget);
113  QAction *insertWidget(QAction *before, QWidget *widget);
114 
115  QRect actionGeometry(QAction *action) const;
116  QAction *actionAt(const QPoint &p) const;
117  inline QAction *actionAt(int x, int y) const;
118 
119  QAction *toggleViewAction() const;
120 
121  QSize iconSize() const;
122  Qt::ToolButtonStyle toolButtonStyle() const;
123 
124  QWidget *widgetForAction(QAction *action) const;
125 
126  bool isFloatable() const;
127  void setFloatable(bool floatable);
128  bool isFloating() const;
129 
130 public Q_SLOTS:
131  void setIconSize(const QSize &iconSize);
132  void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
133 
134 Q_SIGNALS:
135  void actionTriggered(QAction *action);
136  void movableChanged(bool movable);
137  void allowedAreasChanged(Qt::ToolBarAreas allowedAreas);
138  void orientationChanged(Qt::Orientation orientation);
139  void iconSizeChanged(const QSize &iconSize);
140  void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
141  void topLevelChanged(bool topLevel);
142  void visibilityChanged(bool visible);
143 
144 protected:
146  void changeEvent(QEvent *event);
147  void childEvent(QChildEvent *event);
148  void paintEvent(QPaintEvent *event);
149  void resizeEvent(QResizeEvent *event);
150  bool event(QEvent *event);
151  void initStyleOption(QStyleOptionToolBar *option) const;
152 
153 public:
154 #ifdef QT3_SUPPORT
155  QT3_SUPPORT_CONSTRUCTOR QToolBar(QWidget *parent, const char *name);
156  inline QT3_SUPPORT void setLabel(const QString &label)
157  { setWindowTitle(label); }
158  inline QT3_SUPPORT QString label() const
159  { return windowTitle(); }
160 #endif
161 
162 private:
163  Q_DECLARE_PRIVATE(QToolBar)
164  Q_DISABLE_COPY(QToolBar)
165  Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
166  Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &))
167  Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle))
168 
173 };
174 
175 inline QAction *QToolBar::actionAt(int ax, int ay) const
176 { return actionAt(QPoint(ax, ay)); }
177 
178 #endif // QT_NO_TOOLBAR
179 
181 
183 
184 #endif // QDYNAMICTOOLBAR_H
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
QPointer< QWidget > widget
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
bool floating
whether the toolbar is an independent window.
Definition: qtoolbar.h:74
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void clear(QVariant::Private *d)
Definition: qvariant.cpp:197
The QStyleOptionToolBar class is used to describe the parameters for drawing a toolbar.
Definition: qstyleoption.h:369
virtual void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition: qwidget.cpp:9587
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
The QActionEvent class provides an event that is generated when a QAction is added, removed, or changed.
Definition: qevent.h:632
bool movable
whether the user can move the toolbar within the toolbar area, or between toolbar areas ...
Definition: qtoolbar.h:66
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
void addAction(QAction *action)
Appends the action action to this widget&#39;s list of actions.
Definition: qwidget.cpp:3317
virtual void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qwidget.cpp:9548
void setWindowTitle(const QString &)
Definition: qwidget.cpp:6312
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
virtual void childEvent(QChildEvent *)
This event handler can be reimplemented in a subclass to receive child events.
Definition: qobject.cpp:1332
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
const char * name
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
QString windowTitle() const
virtual void actionEvent(QActionEvent *)
This event handler is called with the given event whenever the widget&#39;s actions are changed...
Definition: qwidget.cpp:9600
bool isAreaAllowed(Qt::ToolBarArea area) const
Returns true if this toolbar is dockable in the given area; otherwise returns false.
Definition: qtoolbar.h:88
#define Q_OBJECT
Definition: qobjectdefs.h:157
ToolBarArea
Definition: qnamespace.h:1353
The QChildEvent class contains event parameters for child object events.
Definition: qcoreevent.h:353
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QMainWindow class provides a main application window.
Definition: qmainwindow.h:63
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
ToolButtonStyle
Definition: qnamespace.h:1572
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
Qt::ToolButtonStyle toolButtonStyle
the style of toolbar buttons
Definition: qtoolbar.h:70
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
#define class
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
bool floatable
whether the toolbar can be dragged and dropped as an independent window.
Definition: qtoolbar.h:75
Orientation
Definition: qnamespace.h:174
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
#define text
Definition: qobjectdefs.h:80
static int area(const QSize &s)
Definition: qicon.cpp:155
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60