Qt 4.8
qmainwindow.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 QDYNAMICMAINWINDOW_H
43 #define QDYNAMICMAINWINDOW_H
44 
45 #include <QtGui/qwidget.h>
46 #include <QtGui/qtabwidget.h>
47 
49 
51 
52 QT_MODULE(Gui)
53 
54 #ifndef QT_NO_MAINWINDOW
55 
56 class QDockWidget;
57 class QMainWindowPrivate;
58 class QMenuBar;
59 class QStatusBar;
60 class QToolBar;
61 class QMenu;
62 
64 {
65  Q_OBJECT
66 
68  Q_FLAGS(DockOptions)
69  QSize iconSize;
70  Qt::ToolButtonStyle toolButtonStyle;
71 #ifndef QT_NO_DOCKWIDGET
72  bool animated;
73 #ifndef QT_NO_TABBAR
75 #endif // QT_NO_TABBAR
76 #ifndef QT_NO_TABWIDGET
78 #endif // QT_NO_TABWIDGET
80 #endif // QT_NO_DOCKWIDGET
81  DockOptions dockOptions;
82 #ifndef QT_NO_TOOLBAR
84 #endif
85 
86 public:
87  enum DockOption {
88  AnimatedDocks = 0x01,
89  AllowNestedDocks = 0x02,
90  AllowTabbedDocks = 0x04,
91  ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks
92  VerticalTabs = 0x10 // implies AllowTabbedDocks
93  };
94  Q_DECLARE_FLAGS(DockOptions, DockOption)
95 
96  explicit QMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
97  ~QMainWindow();
98 
99  QSize iconSize() const;
100  void setIconSize(const QSize &iconSize);
101 
102  Qt::ToolButtonStyle toolButtonStyle() const;
103  void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
104 
105 #ifndef QT_NO_DOCKWIDGET
106  bool isAnimated() const;
107  bool isDockNestingEnabled() const;
108 #endif
109 
110 #ifndef QT_NO_TABBAR
111  bool documentMode() const;
112  void setDocumentMode(bool enabled);
113 #endif
114 
115 #ifndef QT_NO_TABWIDGET
116  QTabWidget::TabShape tabShape() const;
117  void setTabShape(QTabWidget::TabShape tabShape);
119  void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
120 #endif // QT_NO_TABWIDGET
121 
122  void setDockOptions(DockOptions options);
123  DockOptions dockOptions() const;
124 
125  bool isSeparator(const QPoint &pos) const;
126 
127 #ifndef QT_NO_MENUBAR
128  QMenuBar *menuBar() const;
129  void setMenuBar(QMenuBar *menubar);
130 
131  QWidget *menuWidget() const;
132  void setMenuWidget(QWidget *menubar);
133 #endif
134 
135 #ifndef QT_NO_STATUSBAR
136  QStatusBar *statusBar() const;
137  void setStatusBar(QStatusBar *statusbar);
138 #endif
139 
140  QWidget *centralWidget() const;
141  void setCentralWidget(QWidget *widget);
142 
143 #ifndef QT_NO_DOCKWIDGET
144  void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
145  Qt::DockWidgetArea corner(Qt::Corner corner) const;
146 #endif
147 
148 #ifndef QT_NO_TOOLBAR
149  void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
150  void insertToolBarBreak(QToolBar *before);
151 
152  void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar);
153  void addToolBar(QToolBar *toolbar);
154  QToolBar *addToolBar(const QString &title);
155  void insertToolBar(QToolBar *before, QToolBar *toolbar);
156  void removeToolBar(QToolBar *toolbar);
157  void removeToolBarBreak(QToolBar *before);
158 
159  void setUnifiedTitleAndToolBarOnMac(bool set);
160  bool unifiedTitleAndToolBarOnMac() const;
161 
162  Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
163  bool toolBarBreak(QToolBar *toolbar) const;
164 #endif
165 #ifndef QT_NO_DOCKWIDGET
166  void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
167  void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget,
168  Qt::Orientation orientation);
169  void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
170  Qt::Orientation orientation);
171  void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
172  QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const;
173  void removeDockWidget(QDockWidget *dockwidget);
174  bool restoreDockWidget(QDockWidget *dockwidget);
175 
176  Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
177 #endif // QT_NO_DOCKWIDGET
178 
179  QByteArray saveState(int version = 0) const;
180  bool restoreState(const QByteArray &state, int version = 0);
181 
182 #ifndef QT_NO_MENU
183  virtual QMenu *createPopupMenu();
184 #endif
185 
186 #ifdef QT3_SUPPORT
187  QT3_SUPPORT_CONSTRUCTOR QMainWindow(QWidget *parent, const char *name, Qt::WindowFlags flags = 0);
188 #endif
189 
190 #ifndef QT_NO_DOCKWIDGET
191 public Q_SLOTS:
192  void setAnimated(bool enabled);
193  void setDockNestingEnabled(bool enabled);
194 #endif
195 
196 Q_SIGNALS:
197  void iconSizeChanged(const QSize &iconSize);
198  void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
199 
200 protected:
201 #ifndef QT_NO_CONTEXTMENU
203 #endif
204  bool event(QEvent *event);
205 
206 private:
209 };
210 
211 Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions)
212 
213 #endif // QT_NO_MAINWINDOW
214 
216 
218 
219 #endif // QDYNAMICMAINWINDOW_H
DockOptions dockOptions
the docking behavior of QMainWindow
Definition: qmainwindow.h:81
QTabWidget::TabShape tabShape
the tab shape used for tabbed dock widgets.
Definition: qmainwindow.h:77
#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
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition: qdockwidget.h:60
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
TabPosition
This enum type defines where QTabWidget draws the tab row:
Definition: qtabwidget.h:112
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_SIGNALS
Definition: qobjectdefs.h:72
NSToolbar * toolbar
The QStatusBar class provides a horizontal bar suitable for presenting status information.
Definition: qstatusbar.h:57
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
The QToolBar class provides a movable panel that contains a set of controls.
Definition: qtoolbar.h:62
const char * name
bool documentMode
whether the tab bar for tabbed dockwidgets is set to document mode.
Definition: qmainwindow.h:74
static bool isSeparator(register char c)
#define Q_OBJECT
Definition: qobjectdefs.h:157
ToolBarArea
Definition: qnamespace.h:1353
Corner
Definition: qnamespace.h:1456
virtual void contextMenuEvent(QContextMenuEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive widget context men...
Definition: qwidget.cpp:9645
bool unifiedTitleAndToolBarOnMac
whether the window uses the unified title and toolbar look on Mac OS X
Definition: qmainwindow.h:83
DockWidgetArea
Definition: qnamespace.h:1337
The QMenuBar class provides a horizontal menu bar.
Definition: qmenubar.h:62
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
bool dockNestingEnabled
whether docks can be nested
Definition: qmainwindow.h:79
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
Definition: qnamespace.h:54
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_FLAGS(x)
Definition: qobjectdefs.h:85
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
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
bool animated
whether manipulating dock widgets and tool bars is animated
Definition: qmainwindow.h:72
#define enabled
TabShape
This enum type defines the shape of the tabs:
Definition: qtabwidget.h:126
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
static int area(const QSize &s)
Definition: qicon.cpp:155
DockOption
This enum contains flags that specify the docking behavior of QMainWindow.
Definition: qmainwindow.h:87