source: trunk/doc/html/qmainwindow.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 62.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qmainwindow.cpp:506 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QMainWindow Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QMainWindow Class Reference</h1>
33
34<p>The QMainWindow class provides a main application window,
35with a menu bar, dock windows (e.g. for toolbars), and a status
36bar.
37<a href="#details">More...</a>
38<p><tt>#include &lt;<a href="qmainwindow-h.html">qmainwindow.h</a>&gt;</tt>
39<p>Inherits <a href="qwidget.html">QWidget</a>.
40<p><a href="qmainwindow-members.html">List of all member functions.</a>
41<h2>Public Members</h2>
42<ul>
43<li class=fn><a href="#QMainWindow"><b>QMainWindow</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = WType_TopLevel )</li>
44<li class=fn><a href="#~QMainWindow"><b>~QMainWindow</b></a> ()</li>
45<li class=fn>QMenuBar * <a href="#menuBar"><b>menuBar</b></a> () const</li>
46<li class=fn>QStatusBar * <a href="#statusBar"><b>statusBar</b></a> () const</li>
47<li class=fn>QToolTipGroup * <a href="#toolTipGroup"><b>toolTipGroup</b></a> () const</li>
48<li class=fn>virtual void <a href="#setCentralWidget"><b>setCentralWidget</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
49<li class=fn>QWidget * <a href="#centralWidget"><b>centralWidget</b></a> () const</li>
50<li class=fn>virtual void <a href="#setDockEnabled"><b>setDockEnabled</b></a> ( Dock&nbsp;dock, bool&nbsp;enable )</li>
51<li class=fn>bool <a href="#isDockEnabled"><b>isDockEnabled</b></a> ( Dock&nbsp;dock ) const</li>
52<li class=fn>bool <a href="#isDockEnabled-2"><b>isDockEnabled</b></a> ( QDockArea&nbsp;*&nbsp;area ) const</li>
53<li class=fn>virtual void <a href="#setDockEnabled-2"><b>setDockEnabled</b></a> ( QDockWindow&nbsp;*&nbsp;dw, Dock&nbsp;dock, bool&nbsp;enable )</li>
54<li class=fn>bool <a href="#isDockEnabled-3"><b>isDockEnabled</b></a> ( QDockWindow&nbsp;*&nbsp;tb, Dock&nbsp;dock ) const</li>
55<li class=fn>bool <a href="#isDockEnabled-4"><b>isDockEnabled</b></a> ( QDockWindow&nbsp;*&nbsp;dw, QDockArea&nbsp;*&nbsp;area ) const</li>
56<li class=fn>virtual void <a href="#addDockWindow"><b>addDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow, Dock&nbsp;edge = DockTop, bool&nbsp;newLine = FALSE )</li>
57<li class=fn>virtual void <a href="#addDockWindow-2"><b>addDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow, const&nbsp;QString&nbsp;&amp;&nbsp;label, Dock&nbsp;edge = DockTop, bool&nbsp;newLine = FALSE )</li>
58<li class=fn>virtual void <a href="#moveDockWindow"><b>moveDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow, Dock&nbsp;edge = DockTop )</li>
59<li class=fn>virtual void <a href="#moveDockWindow-2"><b>moveDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow, Dock&nbsp;edge, bool&nbsp;nl, int&nbsp;index, int&nbsp;extraOffset = -1 )</li>
60<li class=fn>virtual void <a href="#removeDockWindow"><b>removeDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow )</li>
61<li class=fn>bool rightJustification () const &nbsp;<em>(obsolete)</em></li>
62<li class=fn>bool <a href="#usesBigPixmaps"><b>usesBigPixmaps</b></a> () const</li>
63<li class=fn>bool <a href="#usesTextLabel"><b>usesTextLabel</b></a> () const</li>
64<li class=fn>bool <a href="#dockWindowsMovable"><b>dockWindowsMovable</b></a> () const</li>
65<li class=fn>bool <a href="#opaqueMoving"><b>opaqueMoving</b></a> () const</li>
66<li class=fn>bool <a href="#getLocation"><b>getLocation</b></a> ( QDockWindow&nbsp;*&nbsp;dw, Dock&nbsp;&amp;&nbsp;dock, int&nbsp;&amp;&nbsp;index, bool&nbsp;&amp;&nbsp;nl, int&nbsp;&amp;&nbsp;extraOffset ) const</li>
67<li class=fn>QPtrList&lt;QDockWindow&gt; <a href="#dockWindows"><b>dockWindows</b></a> ( Dock&nbsp;dock ) const</li>
68<li class=fn>QPtrList&lt;QDockWindow&gt; <a href="#dockWindows-2"><b>dockWindows</b></a> () const</li>
69<li class=fn>void <a href="#lineUpDockWindows"><b>lineUpDockWindows</b></a> ( bool&nbsp;keepNewLines = FALSE )</li>
70<li class=fn>bool <a href="#isDockMenuEnabled"><b>isDockMenuEnabled</b></a> () const</li>
71<li class=fn>bool <a href="#hasDockWindow"><b>hasDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dw )</li>
72<li class=fn>void addToolBar ( QDockWindow *, Dock = DockTop, bool&nbsp;newLine = FALSE ) &nbsp;<em>(obsolete)</em></li>
73<li class=fn>void addToolBar ( QDockWindow *, const&nbsp;QString&nbsp;&amp;&nbsp;label, Dock = DockTop, bool&nbsp;newLine = FALSE ) &nbsp;<em>(obsolete)</em></li>
74<li class=fn>void moveToolBar ( QDockWindow *, Dock = DockTop ) &nbsp;<em>(obsolete)</em></li>
75<li class=fn>void moveToolBar ( QDockWindow *, Dock, bool&nbsp;nl, int&nbsp;index, int&nbsp;extraOffset = -1 ) &nbsp;<em>(obsolete)</em></li>
76<li class=fn>void removeToolBar ( QDockWindow * ) &nbsp;<em>(obsolete)</em></li>
77<li class=fn>bool toolBarsMovable () const &nbsp;<em>(obsolete)</em></li>
78<li class=fn>QPtrList&lt;QToolBar&gt; <a href="#toolBars"><b>toolBars</b></a> ( Dock&nbsp;dock ) const</li>
79<li class=fn>void lineUpToolBars ( bool&nbsp;keepNewLines = FALSE ) &nbsp;<em>(obsolete)</em></li>
80<li class=fn>QDockArea * <a href="#leftDock"><b>leftDock</b></a> () const</li>
81<li class=fn>QDockArea * <a href="#rightDock"><b>rightDock</b></a> () const</li>
82<li class=fn>QDockArea * <a href="#topDock"><b>topDock</b></a> () const</li>
83<li class=fn>QDockArea * <a href="#bottomDock"><b>bottomDock</b></a> () const</li>
84<li class=fn>virtual bool <a href="#isCustomizable"><b>isCustomizable</b></a> () const</li>
85<li class=fn>bool <a href="#appropriate"><b>appropriate</b></a> ( QDockWindow&nbsp;*&nbsp;dw ) const</li>
86<li class=fn>enum <a href="#DockWindows-enum"><b>DockWindows</b></a> { OnlyToolBars, NoToolBars, AllDockWindows }</li>
87<li class=fn>QPopupMenu * <a href="#createDockWindowMenu"><b>createDockWindowMenu</b></a> ( DockWindows&nbsp;dockWindows = AllDockWindows ) const</li>
88</ul>
89<h2>Public Slots</h2>
90<ul>
91<li class=fn>virtual void setRightJustification ( bool ) &nbsp;<em>(obsolete)</em></li>
92<li class=fn>virtual void <a href="#setUsesBigPixmaps"><b>setUsesBigPixmaps</b></a> ( bool )</li>
93<li class=fn>virtual void <a href="#setUsesTextLabel"><b>setUsesTextLabel</b></a> ( bool )</li>
94<li class=fn>virtual void <a href="#setDockWindowsMovable"><b>setDockWindowsMovable</b></a> ( bool )</li>
95<li class=fn>virtual void <a href="#setOpaqueMoving"><b>setOpaqueMoving</b></a> ( bool )</li>
96<li class=fn>virtual void <a href="#setDockMenuEnabled"><b>setDockMenuEnabled</b></a> ( bool&nbsp;b )</li>
97<li class=fn>virtual void <a href="#whatsThis"><b>whatsThis</b></a> ()</li>
98<li class=fn>virtual void <a href="#setAppropriate"><b>setAppropriate</b></a> ( QDockWindow&nbsp;*&nbsp;dw, bool&nbsp;a )</li>
99<li class=fn>virtual void <a href="#customize"><b>customize</b></a> ()</li>
100<li class=fn>void setToolBarsMovable ( bool ) &nbsp;<em>(obsolete)</em></li>
101</ul>
102<h2>Signals</h2>
103<ul>
104<li class=fn>void <a href="#pixmapSizeChanged"><b>pixmapSizeChanged</b></a> ( bool )</li>
105<li class=fn>void <a href="#usesTextLabelChanged"><b>usesTextLabelChanged</b></a> ( bool )</li>
106<li class=fn>void <a href="#dockWindowPositionChanged"><b>dockWindowPositionChanged</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow )</li>
107<li class=fn>void toolBarPositionChanged ( QToolBar * ) &nbsp;<em>(obsolete)</em></li>
108</ul>
109<h2>Properties</h2>
110<ul>
111<li class=fn>bool <a href="#dockWindowsMovable-prop"><b>dockWindowsMovable</b></a>&nbsp;- whether the dock windows are movable</li>
112<li class=fn>bool <a href="#opaqueMoving-prop"><b>opaqueMoving</b></a>&nbsp;- whether dock windows are moved opaquely</li>
113<li class=fn>bool rightJustification&nbsp;- whether the main window right-justifies its dock windows &nbsp;<em>(obsolete)</em></li>
114<li class=fn>bool <a href="#usesBigPixmaps-prop"><b>usesBigPixmaps</b></a>&nbsp;- whether big pixmaps are enabled</li>
115<li class=fn>bool <a href="#usesTextLabel-prop"><b>usesTextLabel</b></a>&nbsp;- whether text labels for toolbar buttons are enabled</li>
116</ul>
117<h2>Protected Members</h2>
118<ul>
119<li class=fn>virtual void <a href="#childEvent"><b>childEvent</b></a> ( QChildEvent&nbsp;*&nbsp;e )</li>
120</ul>
121<h2>Protected Slots</h2>
122<ul>
123<li class=fn>virtual void <a href="#setUpLayout"><b>setUpLayout</b></a> ()</li>
124<li class=fn>virtual bool <a href="#showDockMenu"><b>showDockMenu</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;globalPos )</li>
125<li class=fn>void <a href="#menuAboutToShow"><b>menuAboutToShow</b></a> ()</li>
126</ul>
127<h2>Related Functions</h2>
128<ul>
129<li class=fn>QTextStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QTextStream&nbsp;&amp;&nbsp;ts, const&nbsp;QMainWindow&nbsp;&amp;&nbsp;mainWindow )</li>
130<li class=fn>QTextStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QTextStream&nbsp;&amp;&nbsp;ts, QMainWindow&nbsp;&amp;&nbsp;mainWindow )</li>
131</ul>
132<hr><a name="details"></a><h2>Detailed Description</h2>
133
134
135The QMainWindow class provides a main application window,
136with a menu bar, dock windows (e.g. for toolbars), and a status
137bar.
138<p>
139
140<p> Main windows are most often used to provide menus, toolbars and a
141status bar around a large central widget, such as a text edit,
142drawing canvas or <a href="qworkspace.html">QWorkspace</a> (for MDI applications). QMainWindow
143is usually subclassed since this makes it easier to encapsulate
144the central widget, menus and toolbars as well as the window's
145state. Subclassing makes it possible to create the slots that are
146called when the user clicks menu items or toolbar buttons. You can
147also create main windows using <a href="designer-manual.html">Qt
148 Designer</a>. We'll briefly review adding menu items and
149toolbar buttons then describe the facilities of QMainWindow
150itself.
151<p> <pre>
152 QMainWindow *mw = new QMainWindow;
153 <a href="qtextedit.html">QTextEdit</a> *edit = new <a href="qtextedit.html">QTextEdit</a>( mw, "editor" );
154 edit-&gt;<a href="qwidget.html#setFocus">setFocus</a>();
155 mw-&gt;<a href="qwidget.html#setCaption">setCaption</a>( "Main Window" );
156 mw-&gt;<a href="#setCentralWidget">setCentralWidget</a>( edit );
157 mw-&gt;<a href="qwidget.html#show">show</a>();
158 </pre>
159
160<p> QMainWindows may be created in their own right as shown above.
161The central widget is set with <a href="#setCentralWidget">setCentralWidget</a>(). Popup menus can
162be added to the default menu bar, widgets can be added to the
163status bar, toolbars and dock windows can be added to any of the
164dock areas.
165<p>
166
167<pre> ApplicationWindow *mw = new ApplicationWindow();
168 mw-&gt;<a href="qwidget.html#setCaption">setCaption</a>( "Qt Example - Application" );
169 <a name="x2115"></a> mw-&gt;<a href="qwidget.html#show">show</a>();
170</pre>
171<p> In the extract above ApplicationWindow is a subclass of
172QMainWindow that we must write for ourselves; this is the usual
173approach to using QMainWindow. (The source for the extracts in
174this description are taken from <a href="simple-application-example.html">application/main.cpp</a>, <a href="simple-application-example.html">application/application.cpp</a>, <a href="qaction-application-example.html">action/main.cpp</a>, and <a href="qaction-application-example.html">action/application.cpp</a> )
175<p> When subclassing we add the menu items and toolbars in the
176subclass's constructor. If we've created a QMainWindow instance
177directly we can add menu items and toolbars just as easily by
178passing the QMainWindow instance as the parent instead of the <em>this</em> pointer.
179<p>
180
181<pre> <a href="qpopupmenu.html">QPopupMenu</a> * help = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
182 <a href="#menuBar">menuBar</a>()-&gt;insertItem( "&amp;Help", help );
183
184 help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;About", this, SLOT(about()), Key_F1 );
185</pre>
186<p> Here we've added a new menu with one menu item. The menu has been
187inserted into the menu bar that QMainWindow provides by default
188and which is accessible through the <a href="#menuBar">menuBar</a>() function. The slot
189will be called when the menu item is clicked.
190<p>
191
192<pre> <a href="qtoolbar.html">QToolBar</a> * fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );
193 fileTools-&gt;<a href="qtoolbar.html#setLabel">setLabel</a>( "File Operations" );
194</pre><pre> QToolButton * fileOpen
195 = new <a href="qtoolbutton.html">QToolButton</a>( openIcon, "Open File", <a href="qstring.html#QString-null">QString::null</a>,
196 this, SLOT(choose()), fileTools, "open file" );
197</pre>
198<p> This extract shows the creation of a toolbar with one toolbar
199button. QMainWindow supplies four dock areas for toolbars. When a
200toolbar is created as a child of a QMainWindow (or derived class)
201instance it will be placed in a dock area (the <a href="qt.html#Dock-enum">Top</a> dock area by
202default). The slot will be called when the toolbar button is
203clicked. Any dock window can be added to a dock area either using
204<a href="#addDockWindow">addDockWindow</a>(), or by creating a dock window with the QMainWindow
205as the parent.
206<p>
207
208<pre> e = new <a href="qtextedit.html">QTextEdit</a>( this, "editor" );
209 e-&gt;<a href="qwidget.html#setFocus">setFocus</a>();
210 <a href="#setCentralWidget">setCentralWidget</a>( e );
211 <a href="#statusBar">statusBar</a>()-&gt;message( "Ready", 2000 );
212</pre>
213<p> Having created the menus and toolbar we create an instance of the
214large central widget, give it the focus and set it as the main
215window's central widget. In the example we've also set the status
216bar, accessed via the <a href="#statusBar">statusBar</a>() function, to an initial message
217which will be displayed for two seconds. Note that you can add
218additional widgets to the status bar, for example labels, to show
219further status information. See the <a href="qstatusbar.html">QStatusBar</a> documentation for
220details, particularly the addWidget() function.
221<p> Often we want to synchronize a toolbar button with a menu item.
222For example, if the user clicks a 'bold' toolbar button we want
223the 'bold' menu item to be checked. This synchronization can be
224achieved automatically by creating actions and adding the actions
225to the toolbar and menu.
226<p>
227
228<pre> <a href="qaction.html">QAction</a> * fileOpenAction;
229</pre><pre> fileOpenAction = new <a href="qaction.html">QAction</a>( QPixmap( fileopen ), "&amp;Open...",
230 CTRL+Key_O, this, "open" );
231 <a href="qobject.html#connect">connect</a>( fileOpenAction, SIGNAL( <a href="qaction.html#activated">activated</a>() ) , this, SLOT( choose() ) );
232</pre>
233<p> Here we create an action with an icon which will be used in any
234menu and toolbar that the action is added to. We've also given the
235action a menu name, '&amp;Open', and a keyboard shortcut. The
236connection that we have made will be used when the user clicks
237either the menu item <em>or</em> the toolbar button.
238<p>
239
240<pre> <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
241 <a href="#menuBar">menuBar</a>()-&gt;insertItem( "&amp;File", file );
242</pre><pre> fileOpenAction-&gt;<a href="qaction.html#addTo">addTo</a>( file );
243</pre>
244<p> The extract above shows the creation of a popup menu. We add the
245menu to the QMainWindow's menu bar and add our action.
246<p>
247
248<pre> <a href="qtoolbar.html">QToolBar</a> * fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );
249 fileTools-&gt;<a href="qtoolbar.html#setLabel">setLabel</a>( "File Operations" );
250 fileOpenAction-&gt;<a href="qaction.html#addTo">addTo</a>( fileTools );
251</pre>
252<p> Here we create a new toolbar as a child of the QMainWindow and add
253our action to the toolbar.
254<p> We'll now explore the functionality offered by QMainWindow.
255<p> The main window will take care of the dock areas, and the geometry
256of the central widget, but all other aspects of the central widget
257are left to you. QMainWindow automatically detects the creation of
258a menu bar or status bar if you specify the QMainWindow as parent,
259or you can use the provided <a href="#menuBar">menuBar</a>() and <a href="#statusBar">statusBar</a>() functions.
260The functions menuBar() and statusBar() create a suitable widget
261if one doesn't exist, and update the window's layout to make
262space.
263<p> QMainWindow provides a <a href="qtooltipgroup.html">QToolTipGroup</a> connected to the status bar.
264The function <a href="#toolTipGroup">toolTipGroup</a>() provides access to the default
265QToolTipGroup. It isn't possible to set a different tool tip
266group.
267<p> New dock windows and toolbars can be added to a QMainWindow using
268<a href="#addDockWindow">addDockWindow</a>(). Dock windows can be moved using <a href="#moveDockWindow">moveDockWindow</a>()
269and removed with <a href="#removeDockWindow">removeDockWindow</a>(). QMainWindow allows default
270dock window (toolbar) docking in all its dock areas (<a href="qt.html#Dock-enum">Top</a>, <a href="qt.html#Dock-enum">Left</a>, <a href="qt.html#Dock-enum">Right</a>, <a href="qt.html#Dock-enum">Bottom</a>). You can use <a href="#setDockEnabled">setDockEnabled</a>() to
271enable and disable docking areas for dock windows. When adding or
272moving dock windows you can specify their 'edge' (dock area). The
273currently available edges are: <a href="qt.html#Dock-enum">Top</a>, <a href="qt.html#Dock-enum">Left</a>, <a href="qt.html#Dock-enum">Right</a>, <a href="qt.html#Dock-enum">Bottom</a>, <a href="qt.html#Dock-enum">Minimized</a> (effectively a 'hidden' dock area) and <a href="qt.html#Dock-enum">TornOff</a> (floating). See <a href="qt.html#Dock-enum">Qt::Dock</a> for an explanation of these
274areas. Note that the *ToolBar functions are included for backward
275compatibility; all new code should use the *DockWindow functions.
276QToolbar is a subclass of <a href="qdockwindow.html">QDockWindow</a> so all functions that work
277with dock windows work on toolbars in the same way.
278<p> <a name="dwm"></a>
279If the user clicks the close button, then the dock window is
280hidden. A dock window can be hidden or unhidden by the user by
281right clicking a dock area and clicking the name of the relevant
282dock window on the pop up dock window menu. This menu lists the
283names of every dock window; visible dock windows have a tick
284beside their names. The dock window menu is created automatically
285as required by <a href="#createDockWindowMenu">createDockWindowMenu</a>(). Since it may not always be
286appropriate for a dock window to appear on this menu the
287<a href="#setAppropriate">setAppropriate</a>() function is used to inform the main window
288whether or not the dock window menu should include a particular
289dock window. Double clicking a dock window handle (usually on the
290left-hand side of the dock window) undocks (floats) the dock
291window. Double clicking a floating dock window's titlebar will
292dock the floating dock window. (See also
293<a href="#DockWindows-enum">QMainWindow::DockWindows</a>.)
294<p> Some functions change the appearance of a QMainWindow globally:
295<ul>
296<li> <a href="qdockwindow.html#setHorizontalStretchable">QDockWindow::setHorizontalStretchable</a>() and
297<a href="qdockwindow.html#setVerticalStretchable">QDockWindow::setVerticalStretchable</a>() are used to make specific dock
298windows or toolbars stretchable.
299<li> <a href="#setUsesBigPixmaps">setUsesBigPixmaps</a>() is used to set whether tool buttons should
300draw small or large pixmaps (see <a href="qiconset.html">QIconSet</a> for more information).
301<li> <a href="#setUsesTextLabel">setUsesTextLabel</a>() is used to set whether tool buttons
302should display a textual label in addition to pixmaps
303(see <a href="qtoolbutton.html">QToolButton</a> for more information).
304</ul>
305<p> The user can drag dock windows into any enabled docking area. Dock
306windows can also be dragged <em>within</em> a docking area, for example
307to rearrange the order of some toolbars. Dock windows can also be
308dragged outside any docking area (undocked or 'floated'). Being
309able to drag dock windows can be enabled (the default) and
310disabled using <a href="#setDockWindowsMovable">setDockWindowsMovable</a>().
311<p> The <a href="qt.html#Dock-enum">Minimized</a> edge is a hidden dock area. If this dock area is
312enabled the user can hide (minimize) a dock window or show (restore)
313a minimized dock window by clicking the dock window handle. If the
314user hovers the mouse cursor over one of the handles, the caption of
315the dock window is displayed in a tool tip (see
316<a href="qwidget.html#caption">QDockWindow::caption</a>() or <a href="qtoolbar.html#label">QToolBar::label</a>()), so if you enable the
317<a href="qt.html#Dock-enum">Minimized</a> dock area, it is best to specify a meaningful caption
318or label for each dock window. To minimize a dock window
319programmatically use <a href="#moveDockWindow">moveDockWindow</a>() with an edge of <a href="qt.html#Dock-enum">Minimized</a>.
320<p> Dock windows are moved transparently by default, i.e. during the
321drag an outline rectangle is drawn on the screen representing the
322position of the dock window as it moves. If you want the dock
323window to be shown normally whilst it is moved use
324<a href="#setOpaqueMoving">setOpaqueMoving</a>().
325<p> The location of a dock window, i.e. its dock area and position
326within the dock area, can be determined by calling <a href="#getLocation">getLocation</a>().
327Movable dock windows can be lined up to minimize wasted space with
328<a href="#lineUpDockWindows">lineUpDockWindows</a>(). Pointers to the dock areas are available from
329<a href="#topDock">topDock</a>(), <a href="#leftDock">leftDock</a>(), <a href="#rightDock">rightDock</a>() and <a href="#bottomDock">bottomDock</a>(). A customize
330menu item is added to the pop up dock window menu if
331<a href="#isCustomizable">isCustomizable</a>() returns TRUE; it returns FALSE by default.
332Reimplement isCustomizable() and <a href="#customize">customize</a>() if you want to offer
333this extra menu item, for example, to allow the user to change
334settings relating to the main window and its toolbars and dock
335windows.
336<p> The main window's menu bar is fixed (at the top) by default. If
337you want a movable menu bar, create a <a href="qmenubar.html">QMenuBar</a> as a stretchable
338widget inside its own movable dock window and restrict this dock
339window to only live within the <a href="qt.html#Dock-enum">Top</a> or <a href="qt.html#Dock-enum">Bottom</a> dock:
340<p> <pre>
341 <a href="qtoolbar.html">QToolBar</a> *tb = new <a href="qtoolbar.html">QToolBar</a>( this );
342 <a href="#addDockWindow">addDockWindow</a>( tb, tr( "Menubar" ), Top, FALSE );
343 <a href="qmenubar.html">QMenuBar</a> *mb = new <a href="qmenubar.html">QMenuBar</a>( tb );
344 mb-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::NoFrame );
345 tb-&gt;<a href="qtoolbar.html#setStretchableWidget">setStretchableWidget</a>( mb );
346 <a href="#setDockEnabled">setDockEnabled</a>( tb, Left, FALSE );
347 <a href="#setDockEnabled">setDockEnabled</a>( tb, Right, FALSE );
348 </pre>
349
350<p> An application with multiple dock windows can choose to save the
351current dock window layout in order to restore it later, e.g. in
352the next session. You can do this by using the streaming operators
353for QMainWindow.
354<p> To save the layout and positions of all the dock windows do this:
355<p> <pre>
356 <a href="qfile.html">QFile</a> file( filename );
357 if ( file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_WriteOnly</a> ) ) {
358 <a href="qtextstream.html">QTextStream</a> stream( &amp;file );
359 stream &lt;&lt; *mainWindow;
360 file.<a href="qfile.html#close">close</a>();
361 }
362 </pre>
363
364<p> To restore the dock window positions and sizes (normally when the
365application is next started), do following:
366<p> <pre>
367 <a href="qfile.html">QFile</a> file( filename );
368 if ( file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) ) {
369 <a href="qtextstream.html">QTextStream</a> stream( &amp;file );
370 stream &gt;&gt; *mainWindow;
371 file.<a href="qfile.html#close">close</a>();
372 }
373 </pre>
374
375<p> The <a href="qsettings.html">QSettings</a> class can be used in conjunction with the streaming
376operators to store the application's settings.
377<p> QMainWindow's management of dock windows and toolbars is done
378transparently behind-the-scenes by <a href="qdockarea.html">QDockArea</a>.
379<p> For multi-document interfaces (MDI), use a <a href="qworkspace.html">QWorkspace</a> as the
380central widget.
381<p> Adding dock windows, e.g. toolbars, to QMainWindow's dock areas is
382straightforward. If the supplied dock areas are not sufficient for
383your application we suggest that you create a <a href="qwidget.html">QWidget</a> subclass and
384add your own dock areas (see <a href="qdockarea.html">QDockArea</a>) to the subclass since
385QMainWindow provides functionality specific to the standard dock
386areas it provides.
387<p> <img src=qmainwindow-m.png> <img src=qmainwindow-w.png>
388<p> <p>See also <a href="qtoolbar.html">QToolBar</a>, <a href="qdockwindow.html">QDockWindow</a>, <a href="qstatusbar.html">QStatusBar</a>, <a href="qaction.html">QAction</a>, <a href="qmenubar.html">QMenuBar</a>, <a href="qpopupmenu.html">QPopupMenu</a>, <a href="qtooltipgroup.html">QToolTipGroup</a>, <a href="qdialog.html">QDialog</a>, and <a href="application.html">Main Window and Related Classes</a>.
389
390<hr><h2>Member Type Documentation</h2>
391<h3 class=fn><a name="DockWindows-enum"></a>QMainWindow::DockWindows</h3>
392
393<p> Right-clicking a dock area will pop-up the dock window menu
394(<a href="#createDockWindowMenu">createDockWindowMenu</a>() is called automatically). When called in
395code you can specify what items should appear on the menu with
396this enum.
397<ul>
398<li><tt>QMainWindow::OnlyToolBars</tt> - The menu will list all the toolbars, but not
399any other dock windows.
400<li><tt>QMainWindow::NoToolBars</tt> - The menu will list dock windows but not
401toolbars.
402<li><tt>QMainWindow::AllDockWindows</tt> - The menu will list all toolbars and other
403dock windows. (This is the default.)
404</ul>
405<hr><h2>Member Function Documentation</h2>
406<h3 class=fn><a name="QMainWindow"></a>QMainWindow::QMainWindow ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = WType_TopLevel )
407</h3>
408Constructs an empty main window. The <em>parent</em>, <em>name</em> and widget
409flags <em>f</em>, are passed on to the <a href="qwidget.html">QWidget</a> constructor.
410<p> By default, the widget flags are set to <a href="qt.html#WidgetFlags-enum">WType_TopLevel</a> rather
411than 0 as they are with QWidget. If you don't want your
412QMainWindow to be a top level widget then you will need to set <em>f</em> to 0.
413
414<h3 class=fn><a name="~QMainWindow"></a>QMainWindow::~QMainWindow ()
415</h3>
416Destroys the object and frees any allocated resources.
417
418<h3 class=fn>void <a name="addDockWindow"></a>QMainWindow::addDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow, <a href="qt.html#Dock-enum">Dock</a>&nbsp;edge = DockTop, bool&nbsp;newLine = FALSE )<tt> [virtual]</tt>
419</h3>
420Adds <em>dockWindow</em> to the <em>edge</em> dock area.
421<p> If <em>newLine</em> is FALSE (the default) then the <em>dockWindow</em> is
422added at the end of the <em>edge</em>. For vertical edges the end is at
423the bottom, for horizontal edges (including <a href="qt.html#Dock-enum">Minimized</a>) the end
424is at the right. If <em>newLine</em> is TRUE a new line of dock windows
425is started with <em>dockWindow</em> as the first (left-most and
426top-most) dock window.
427<p> If <em>dockWindow</em> is managed by another main window, it is first
428removed from that window.
429
430<h3 class=fn>void <a name="addDockWindow-2"></a>QMainWindow::addDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, <a href="qt.html#Dock-enum">Dock</a>&nbsp;edge = DockTop, bool&nbsp;newLine = FALSE )<tt> [virtual]</tt>
431</h3>
432This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
433<p> Adds <em>dockWindow</em> to the dock area with label <em>label</em>.
434<p> If <em>newLine</em> is FALSE (the default) the <em>dockWindow</em> is added at
435the end of the <em>edge</em>. For vertical edges the end is at the
436bottom, for horizontal edges (including <a href="qt.html#Dock-enum">Minimized</a>) the end is
437at the right. If <em>newLine</em> is TRUE a new line of dock windows is
438started with <em>dockWindow</em> as the first (left-most and top-most)
439dock window.
440<p> If <em>dockWindow</em> is managed by another main window, it is first
441removed from that window.
442
443<h3 class=fn>void <a name="addToolBar"></a>QMainWindow::addToolBar ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*, <a href="qt.html#Dock-enum">Dock</a> = DockTop, bool&nbsp;newLine = FALSE )
444</h3>
445<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
446<p>
447
448<h3 class=fn>void <a name="addToolBar-2"></a>QMainWindow::addToolBar ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, <a href="qt.html#Dock-enum">Dock</a> = DockTop, bool&nbsp;newLine = FALSE )
449</h3>
450<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
451<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
452<p>
453<h3 class=fn>bool <a name="appropriate"></a>QMainWindow::appropriate ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw ) const
454</h3>
455Returns TRUE if it is appropriate to include a menu item for the
456<em>dw</em> dock window in the dock window menu; otherwise returns
457FALSE.
458<p> The user is able to change the state (show or hide) a dock window
459that has a menu item by clicking the item.
460<p> Call <a href="#setAppropriate">setAppropriate</a>() to indicate whether or not a particular dock
461window should appear on the popup menu.
462<p> <p>See also <a href="#setAppropriate">setAppropriate</a>().
463
464<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="bottomDock"></a>QMainWindow::bottomDock () const
465</h3>
466Returns a pointer the <a href="qt.html#Dock-enum">Bottom</a> dock area
467<p> <p>See also <a href="#topDock">topDock</a>(), <a href="#leftDock">leftDock</a>(), and <a href="#rightDock">rightDock</a>().
468
469<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="centralWidget"></a>QMainWindow::centralWidget () const
470</h3>
471Returns a pointer to the main window's central widget.
472<p> The central widget is surrounded by the left, top, right and
473bottom dock areas. The menu bar is above the top dock area.
474<p> <p>See also <a href="#setCentralWidget">setCentralWidget</a>().
475
476<p>Example: <a href="qfd-example.html#x2013">qfd/qfd.cpp</a>.
477<h3 class=fn>void <a name="childEvent"></a>QMainWindow::childEvent ( <a href="qchildevent.html">QChildEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
478</h3>
479Monitors events, recieved in <em>e</em>, to ensure the layout is updated.
480
481<p>Reimplemented from <a href="qobject.html#childEvent">QObject</a>.
482<h3 class=fn><a href="qpopupmenu.html">QPopupMenu</a>&nbsp;* <a name="createDockWindowMenu"></a>QMainWindow::createDockWindowMenu ( <a href="qmainwindow.html#DockWindows-enum">DockWindows</a>&nbsp;dockWindows = AllDockWindows ) const
483</h3>
484Creates the dock window menu which contains all toolbars (if <em>dockWindows</em> is <a href="#DockWindows-enum">OnlyToolBars</a> ), all dock windows (if <em>dockWindows</em> is <a href="#DockWindows-enum">NoToolBars</a>) or all toolbars and dock windows (if
485<em>dockWindows</em> is <a href="#DockWindows-enum">AllDockWindows</a> - the default).
486<p> This function is called internally when necessary, e.g. when the
487user right clicks a dock area (providing <a href="#isDockMenuEnabled">isDockMenuEnabled</a>()
488returns TRUE).
489
490<p> The menu items representing the toolbars and dock windows are
491checkable. The visible dock windows are checked and the hidden
492dock windows are unchecked. The user can click a menu item to
493change its state (show or hide the dock window).
494<p> The list and the state are always kept up-to-date.
495<p> Toolbars and dock windows which are not appropriate in the current
496context (see <a href="#setAppropriate">setAppropriate</a>()) are not listed in the menu.
497<p> The menu also has a menu item for lining up the dock windows.
498<p> If <a href="#isCustomizable">isCustomizable</a>() returns TRUE, a Customize menu item is added
499to the menu, which if clicked will call <a href="#customize">customize</a>(). The
500isCustomizable() function we provide returns FALSE and customize()
501does nothing, so they must be reimplemented in a subclass to be
502useful.
503
504<h3 class=fn>void <a name="customize"></a>QMainWindow::customize ()<tt> [virtual slot]</tt>
505</h3>
506This function is called when the user clicks the Customize menu
507item on the dock window menu.
508<p> The customize menu item will only appear if <a href="#isCustomizable">isCustomizable</a>()
509returns TRUE (it returns FALSE by default).
510<p> The function is intended, for example, to provide the user with a
511means of telling the application that they wish to customize the
512main window, dock windows or dock areas.
513<p> The default implementation does nothing and the Customize menu
514item is not shown on the right-click menu by default. If you want
515the item to appear then reimplement isCustomizable() to return
516TRUE, and reimplement this function to do whatever you want.
517<p> <p>See also <a href="#isCustomizable">isCustomizable</a>().
518
519<h3 class=fn>void <a name="dockWindowPositionChanged"></a>QMainWindow::dockWindowPositionChanged ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow )<tt> [signal]</tt>
520</h3>
521
522<p> This signal is emitted when the <em>dockWindow</em> has changed its
523position. A change in position occurs when a dock window is moved
524within its dock area or moved to another dock area (including the
525<a href="qt.html#Dock-enum">Minimized</a> and <tt>TearOff</tt> dock areas).
526<p> <p>See also <a href="#getLocation">getLocation</a>().
527
528<h3 class=fn><a href="qptrlist.html">QPtrList</a>&lt;QDockWindow&gt; <a name="dockWindows"></a>QMainWindow::dockWindows ( <a href="qt.html#Dock-enum">Dock</a>&nbsp;dock ) const
529</h3>
530Returns a list of all the dock windows which are in the <em>dock</em>
531dock area, regardless of their state.
532<p> For example, the <a href="qt.html#Dock-enum">DockTornOff</a> dock area may contain closed dock
533windows but these are returned along with the visible dock
534windows.
535
536<h3 class=fn><a href="qptrlist.html">QPtrList</a>&lt;QDockWindow&gt; <a name="dockWindows-2"></a>QMainWindow::dockWindows () const
537</h3>
538This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
539<p> Returns the list of dock windows which belong to this main window,
540regardless of which dock area they are in or what their state is,
541(e.g. irrespective of whether they are visible or not).
542
543<h3 class=fn>bool <a name="dockWindowsMovable"></a>QMainWindow::dockWindowsMovable () const
544</h3><p>Returns TRUE if the dock windows are movable; otherwise returns FALSE.
545See the <a href="qmainwindow.html#dockWindowsMovable-prop">"dockWindowsMovable"</a> property for details.
546<h3 class=fn>bool <a name="getLocation"></a>QMainWindow::getLocation ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw, <a href="qt.html#Dock-enum">Dock</a>&nbsp;&amp;&nbsp;dock, int&nbsp;&amp;&nbsp;index, bool&nbsp;&amp;&nbsp;nl, int&nbsp;&amp;&nbsp;extraOffset ) const
547</h3>
548Finds the location of the dock window <em>dw</em>.
549<p> If the <em>dw</em> dock window is found in the main window the function
550returns TRUE and populates the <em>dock</em> variable with the dw's dock
551area and the <em>index</em> with the dw's position within the dock area.
552It also sets <em>nl</em> to TRUE if the <em>dw</em> begins a new line
553(otherwise FALSE), and <em>extraOffset</em> with the dock window's offset.
554<p> If the <em>dw</em> dock window is not found then the function returns
555FALSE and the state of <em>dock</em>, <em>index</em>, <em>nl</em> and <em>extraOffset</em>
556is undefined.
557<p> If you want to save and restore dock window positions then use
558<a href="#operator-gt-gt">operator&gt;&gt;</a>() and <a href="#operator-lt-lt">operator&lt;&lt;</a>().
559<p> <p>See also <a href="#operator-gt-gt">operator&gt;&gt;</a>() and <a href="#operator-lt-lt">operator&lt;&lt;</a>().
560
561<h3 class=fn>bool <a name="hasDockWindow"></a>QMainWindow::hasDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw )
562</h3>
563Returns TRUE if <em>dw</em> is a dock window known to the main window;
564otherwise returns FALSE.
565
566<h3 class=fn>bool <a name="isCustomizable"></a>QMainWindow::isCustomizable () const<tt> [virtual]</tt>
567</h3>
568Returns TRUE if the dock area dock window menu includes the
569Customize menu item (which calls <a href="#customize">customize</a>() when clicked).
570Returns FALSE by default, i.e. the popup menu will not contain a
571Customize menu item. You will need to reimplement this function
572and set it to return TRUE if you wish the user to be able to see
573the dock window menu.
574<p> <p>See also <a href="#customize">customize</a>().
575
576<h3 class=fn>bool <a name="isDockEnabled"></a>QMainWindow::isDockEnabled ( <a href="qt.html#Dock-enum">Dock</a>&nbsp;dock ) const
577</h3>
578Returns TRUE if the <em>dock</em> dock area is enabled, i.e. it can
579accept user dragged dock windows; otherwise returns FALSE.
580<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
581
582<h3 class=fn>bool <a name="isDockEnabled-2"></a>QMainWindow::isDockEnabled ( <a href="qdockarea.html">QDockArea</a>&nbsp;*&nbsp;area ) const
583</h3>
584This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
585<p> Returns TRUE if dock area <em>area</em> is enabled, i.e. it can accept
586user dragged dock windows; otherwise returns FALSE.
587<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
588
589<h3 class=fn>bool <a name="isDockEnabled-3"></a>QMainWindow::isDockEnabled ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;tb, <a href="qt.html#Dock-enum">Dock</a>&nbsp;dock ) const
590</h3>
591This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
592<p> Returns TRUE if dock area <em>dock</em> is enabled for the dock window
593<em>tb</em>; otherwise returns FALSE.
594<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
595
596<h3 class=fn>bool <a name="isDockEnabled-4"></a>QMainWindow::isDockEnabled ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw, <a href="qdockarea.html">QDockArea</a>&nbsp;*&nbsp;area ) const
597</h3>
598This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
599<p> Returns TRUE if dock area <em>area</em> is enabled for the dock window
600<em>dw</em>; otherwise returns FALSE.
601<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
602
603<h3 class=fn>bool <a name="isDockMenuEnabled"></a>QMainWindow::isDockMenuEnabled () const
604</h3>
605Returns TRUE, if the dock window menu is enabled; otherwise
606returns FALSE.
607<p> The menu lists the (<a href="#appropriate">appropriate</a>()) dock windows (which may be
608shown or hidden), and has a "Line Up Dock Windows" menu item. It
609will also have a "Customize" menu item if <a href="#isCustomizable">isCustomizable</a>() returns
610TRUE.
611<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>(), <a href="#lineUpDockWindows">lineUpDockWindows</a>(), <a href="#appropriate">appropriate</a>(), and <a href="#setAppropriate">setAppropriate</a>().
612
613<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="leftDock"></a>QMainWindow::leftDock () const
614</h3>
615Returns the <a href="qt.html#Dock-enum">Left</a> dock area
616<p> <p>See also <a href="#rightDock">rightDock</a>(), <a href="#topDock">topDock</a>(), and <a href="#bottomDock">bottomDock</a>().
617
618<h3 class=fn>void <a name="lineUpDockWindows"></a>QMainWindow::lineUpDockWindows ( bool&nbsp;keepNewLines = FALSE )
619</h3>
620This function will line up dock windows within the visible dock
621areas (<a href="qt.html#Dock-enum">Top</a>, <a href="qt.html#Dock-enum">Left</a>, <a href="qt.html#Dock-enum">Right</a> and <a href="qt.html#Dock-enum">Bottom</a>) as compactly as
622possible.
623<p> If <em>keepNewLines</em> is TRUE, all dock windows stay on their
624original lines. If <em>keepNewLines</em> is FALSE then newlines may be
625removed to achieve the most compact layout possible.
626<p> The method only works if <a href="#dockWindowsMovable">dockWindowsMovable</a>() returns TRUE.
627
628<h3 class=fn>void <a name="lineUpToolBars"></a>QMainWindow::lineUpToolBars ( bool&nbsp;keepNewLines = FALSE )
629</h3>
630<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
631<p>
632
633<h3 class=fn>void <a name="menuAboutToShow"></a>QMainWindow::menuAboutToShow ()<tt> [protected slot]</tt>
634</h3>
635This slot is called from the aboutToShow() signal of the default
636dock menu of the mainwindow. The default implementation
637initializes the menu with all dock windows and toolbars in this
638slot.
639
640
641<h3 class=fn><a href="qmenubar.html">QMenuBar</a>&nbsp;* <a name="menuBar"></a>QMainWindow::menuBar () const
642</h3>
643Returns the menu bar for this window.
644<p> If there isn't one, then <a href="#menuBar">menuBar</a>() creates an empty menu bar.
645<p> <p>See also <a href="#statusBar">statusBar</a>().
646
647<h3 class=fn>void <a name="moveDockWindow"></a>QMainWindow::moveDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow, <a href="qt.html#Dock-enum">Dock</a>&nbsp;edge = DockTop )<tt> [virtual]</tt>
648</h3>
649Moves <em>dockWindow</em> to the end of the <em>edge</em>.
650<p> For vertical edges the end is at the bottom, for horizontal edges
651(including <a href="qt.html#Dock-enum">Minimized</a>) the end is at the right.
652<p> If <em>dockWindow</em> is managed by another main window, it is first
653removed from that window.
654
655<h3 class=fn>void <a name="moveDockWindow-2"></a>QMainWindow::moveDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow, <a href="qt.html#Dock-enum">Dock</a>&nbsp;edge, bool&nbsp;nl, int&nbsp;index, int&nbsp;extraOffset = -1 )<tt> [virtual]</tt>
656</h3>
657This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
658<p> Moves <em>dockWindow</em> to position <em>index</em> within the <em>edge</em> dock
659area.
660<p> Any dock windows with positions <em>index</em> or higher have their
661position number incremented and any of these on the same line are
662moved right (down for vertical dock areas) to make room.
663<p> If <em>nl</em> is TRUE, a new dock window line is created below the line
664in which the moved dock window appears and the moved dock window,
665with any others with higher positions on the same line, is moved
666to this new line.
667<p> The <em>extraOffset</em> is the space to put between the left side of
668the dock area (top side for vertical dock areas) and the dock
669window. (This is mostly used for restoring dock windows to the
670positions the user has dragged them to.)
671<p> If <em>dockWindow</em> is managed by another main window, it is first
672removed from that window.
673
674<h3 class=fn>void <a name="moveToolBar"></a>QMainWindow::moveToolBar ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*, <a href="qt.html#Dock-enum">Dock</a> = DockTop )
675</h3>
676<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
677<p>
678
679<h3 class=fn>void <a name="moveToolBar-2"></a>QMainWindow::moveToolBar ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*, <a href="qt.html#Dock-enum">Dock</a>, bool&nbsp;nl, int&nbsp;index, int&nbsp;extraOffset = -1 )
680</h3>
681<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
682<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
683<p>
684<h3 class=fn>bool <a name="opaqueMoving"></a>QMainWindow::opaqueMoving () const
685</h3><p>Returns TRUE if dock windows are moved opaquely; otherwise returns FALSE.
686See the <a href="qmainwindow.html#opaqueMoving-prop">"opaqueMoving"</a> property for details.
687<h3 class=fn>void <a name="pixmapSizeChanged"></a>QMainWindow::pixmapSizeChanged ( bool )<tt> [signal]</tt>
688</h3>
689
690<p> This signal is emitted whenever the <a href="#setUsesBigPixmaps">setUsesBigPixmaps</a>() is called
691with a value different to the current setting. All widgets that
692should respond to such changes, e.g. toolbar buttons, must connect
693to this signal.
694
695<h3 class=fn>void <a name="removeDockWindow"></a>QMainWindow::removeDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow )<tt> [virtual]</tt>
696</h3>
697Removes <em>dockWindow</em> from the main window's docking area,
698provided <em>dockWindow</em> is non-null and managed by this main
699window.
700
701<h3 class=fn>void <a name="removeToolBar"></a>QMainWindow::removeToolBar ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;* )
702</h3>
703<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
704<p>
705
706<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="rightDock"></a>QMainWindow::rightDock () const
707</h3>
708Returns the <a href="qt.html#Dock-enum">Right</a> dock area
709<p> <p>See also <a href="#leftDock">leftDock</a>(), <a href="#topDock">topDock</a>(), and <a href="#bottomDock">bottomDock</a>().
710
711<h3 class=fn>bool <a name="rightJustification"></a>QMainWindow::rightJustification () const
712</h3><p>Returns TRUE if the main window right-justifies its dock windows; otherwise returns FALSE.
713See the <a href="qmainwindow.html#rightJustification-prop">"rightJustification"</a> property for details.
714<h3 class=fn>void <a name="setAppropriate"></a>QMainWindow::setAppropriate ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw, bool&nbsp;a )<tt> [virtual slot]</tt>
715</h3>
716Use this function to control whether or not the <em>dw</em> dock
717window's caption should appear as a menu item on the dock window
718menu that lists the dock windows.
719<p> If <em>a</em> is TRUE then the <em>dw</em> will appear as a menu item on the
720dock window menu. The user is able to change the state (show or
721hide) a dock window that has a menu item by clicking the item;
722depending on the state of your application, this may or may not be
723appropriate. If <em>a</em> is FALSE the <em>dw</em> will not appear on the
724popup menu.
725<p> <p>See also <a href="#showDockMenu">showDockMenu</a>(), <a href="#isCustomizable">isCustomizable</a>(), and <a href="#customize">customize</a>().
726
727<h3 class=fn>void <a name="setCentralWidget"></a>QMainWindow::setCentralWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
728</h3>
729Sets the central widget for this main window to <em>w</em>.
730<p> The central widget is surrounded by the left, top, right and
731bottom dock areas. The menu bar is above the top dock area.
732<p> <p>See also <a href="#centralWidget">centralWidget</a>().
733
734<h3 class=fn>void <a name="setDockEnabled"></a>QMainWindow::setDockEnabled ( <a href="qt.html#Dock-enum">Dock</a>&nbsp;dock, bool&nbsp;enable )<tt> [virtual]</tt>
735</h3>
736If <em>enable</em> is TRUE then users can dock windows in the <em>dock</em>
737area. If <em>enable</em> is FALSE users cannot dock windows in the <em>dock</em> dock area.
738<p> Users can dock (drag) dock windows into any enabled dock area.
739
740<h3 class=fn>void <a name="setDockEnabled-2"></a>QMainWindow::setDockEnabled ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw, <a href="qt.html#Dock-enum">Dock</a>&nbsp;dock, bool&nbsp;enable )<tt> [virtual]</tt>
741</h3>
742This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
743<p> If <em>enable</em> is TRUE then users can dock the <em>dw</em> dock window in
744the <em>dock</em> area. If <em>enable</em> is FALSE users cannot dock the <em>dw</em> dock window in the <em>dock</em> area.
745<p> In general users can dock (drag) dock windows into any enabled
746dock area. Using this function particular dock areas can be
747enabled (or disabled) as docking points for particular dock
748windows.
749
750<h3 class=fn>void <a name="setDockMenuEnabled"></a>QMainWindow::setDockMenuEnabled ( bool&nbsp;b )<tt> [virtual slot]</tt>
751</h3>
752If <em>b</em> is TRUE, then right clicking on a dock window or dock area
753will pop up the dock window menu. If <em>b</em> is FALSE, right clicking
754a dock window or dock area will not pop up the menu.
755<p> The menu lists the (<a href="#appropriate">appropriate</a>()) dock windows (which may be
756shown or hidden), and has a "Line Up Dock Windows" item. It will
757also have a "Customize" menu item if <a href="#isCustomizable">isCustomizable</a>() returns
758TRUE.
759<p> <p>See also <a href="#lineUpDockWindows">lineUpDockWindows</a>() and <a href="#isDockMenuEnabled">isDockMenuEnabled</a>().
760
761<h3 class=fn>void <a name="setDockWindowsMovable"></a>QMainWindow::setDockWindowsMovable ( bool )<tt> [virtual slot]</tt>
762</h3><p>Sets whether the dock windows are movable.
763See the <a href="qmainwindow.html#dockWindowsMovable-prop">"dockWindowsMovable"</a> property for details.
764<h3 class=fn>void <a name="setOpaqueMoving"></a>QMainWindow::setOpaqueMoving ( bool )<tt> [virtual slot]</tt>
765</h3><p>Sets whether dock windows are moved opaquely.
766See the <a href="qmainwindow.html#opaqueMoving-prop">"opaqueMoving"</a> property for details.
767<h3 class=fn>void <a name="setRightJustification"></a>QMainWindow::setRightJustification ( bool )<tt> [virtual slot]</tt>
768</h3><p>Sets whether the main window right-justifies its dock windows.
769See the <a href="qmainwindow.html#rightJustification-prop">"rightJustification"</a> property for details.
770<h3 class=fn>void <a name="setToolBarsMovable"></a>QMainWindow::setToolBarsMovable ( bool )<tt> [slot]</tt>
771</h3>
772<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
773<p>
774
775<h3 class=fn>void <a name="setUpLayout"></a>QMainWindow::setUpLayout ()<tt> [virtual protected slot]</tt>
776</h3>
777Sets up the geometry management of the window. It is called
778automatically when needed, so you shouldn't need to call it.
779
780<h3 class=fn>void <a name="setUsesBigPixmaps"></a>QMainWindow::setUsesBigPixmaps ( bool )<tt> [virtual slot]</tt>
781</h3><p>Sets whether big pixmaps are enabled.
782See the <a href="qmainwindow.html#usesBigPixmaps-prop">"usesBigPixmaps"</a> property for details.
783<h3 class=fn>void <a name="setUsesTextLabel"></a>QMainWindow::setUsesTextLabel ( bool )<tt> [virtual slot]</tt>
784</h3><p>Sets whether text labels for toolbar buttons are enabled.
785See the <a href="qmainwindow.html#usesTextLabel-prop">"usesTextLabel"</a> property for details.
786<h3 class=fn>bool <a name="showDockMenu"></a>QMainWindow::showDockMenu ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;globalPos )<tt> [virtual protected slot]</tt>
787</h3>
788Shows the dock menu at the position <em>globalPos</em>. The menu lists
789the dock windows so that they can be shown (or hidden), lined up,
790and possibly customized. Returns TRUE if the menu is shown;
791otherwise returns FALSE.
792<p> If you want a custom menu, reimplement this function. You can
793create the menu from scratch or call <a href="#createDockWindowMenu">createDockWindowMenu</a>() and
794modify the result.
795
796
797<h3 class=fn><a href="qstatusbar.html">QStatusBar</a>&nbsp;* <a name="statusBar"></a>QMainWindow::statusBar () const
798</h3>
799Returns this main window's status bar. If there isn't one,
800<a href="#statusBar">statusBar</a>() creates an empty status bar, and if necessary a tool
801tip group too.
802<p> <p>See also <a href="#menuBar">menuBar</a>() and <a href="#toolTipGroup">toolTipGroup</a>().
803
804<p>Example: <a href="qfd-example.html#x2015">qfd/qfd.cpp</a>.
805<h3 class=fn>void <a name="toolBarPositionChanged"></a>QMainWindow::toolBarPositionChanged ( <a href="qtoolbar.html">QToolBar</a>&nbsp;* )<tt> [signal]</tt>
806</h3>
807<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
808<p>
809
810<h3 class=fn><a href="qptrlist.html">QPtrList</a>&lt;QToolBar&gt; <a name="toolBars"></a>QMainWindow::toolBars ( <a href="qt.html#Dock-enum">Dock</a>&nbsp;dock ) const
811</h3>
812Returns a list of all the toolbars which are in the <em>dock</em> dock
813area, regardless of their state.
814<p> For example, the <a href="qt.html#Dock-enum">TornOff</a> dock area may contain closed toolbars
815but these are returned along with the visible toolbars.
816<p> <p>See also <a href="#dockWindows">dockWindows</a>().
817
818<h3 class=fn>bool <a name="toolBarsMovable"></a>QMainWindow::toolBarsMovable () const
819</h3>
820<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
821<p>
822
823<h3 class=fn><a href="qtooltipgroup.html">QToolTipGroup</a>&nbsp;* <a name="toolTipGroup"></a>QMainWindow::toolTipGroup () const
824</h3>
825Returns this main window's tool tip group. If there isn't one,
826<a href="#toolTipGroup">toolTipGroup</a>() creates an empty tool tip group.
827<p> <p>See also <a href="#menuBar">menuBar</a>() and <a href="#statusBar">statusBar</a>().
828
829<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="topDock"></a>QMainWindow::topDock () const
830</h3>
831Returns the <a href="qt.html#Dock-enum">Top</a> dock area
832<p> <p>See also <a href="#bottomDock">bottomDock</a>(), <a href="#leftDock">leftDock</a>(), and <a href="#rightDock">rightDock</a>().
833
834<h3 class=fn>bool <a name="usesBigPixmaps"></a>QMainWindow::usesBigPixmaps () const
835</h3><p>Returns TRUE if big pixmaps are enabled; otherwise returns FALSE.
836See the <a href="qmainwindow.html#usesBigPixmaps-prop">"usesBigPixmaps"</a> property for details.
837<h3 class=fn>bool <a name="usesTextLabel"></a>QMainWindow::usesTextLabel () const
838</h3><p>Returns TRUE if text labels for toolbar buttons are enabled; otherwise returns FALSE.
839See the <a href="qmainwindow.html#usesTextLabel-prop">"usesTextLabel"</a> property for details.
840<h3 class=fn>void <a name="usesTextLabelChanged"></a>QMainWindow::usesTextLabelChanged ( bool )<tt> [signal]</tt>
841</h3>
842
843<p> This signal is emitted whenever the <a href="#setUsesTextLabel">setUsesTextLabel</a>() is called
844with a value different to the current setting. All widgets that
845should respond to such changes, e.g. toolbar buttons, must connect
846to this signal.
847
848<h3 class=fn>void <a name="whatsThis"></a>QMainWindow::whatsThis ()<tt> [virtual slot]</tt>
849</h3>
850Enters 'What's This?' mode and returns immediately.
851<p> This is the same as <a href="qwhatsthis.html#enterWhatsThisMode">QWhatsThis::enterWhatsThisMode</a>(), but
852implemented as a main window object's slot. This way it can easily
853be used for popup menus, for example:
854<p> <pre>
855 <a href="qpopupmenu.html">QPopupMenu</a> * help = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
856 help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "What's &amp;This", this , SLOT(<a href="#whatsThis">whatsThis</a>()), SHIFT+Key_F1);
857 </pre>
858
859<p> <p>See also <a href="qwhatsthis.html#enterWhatsThisMode">QWhatsThis::enterWhatsThisMode</a>().
860
861<hr><h2>Property Documentation</h2>
862<h3 class=fn>bool <a name="dockWindowsMovable-prop"></a>dockWindowsMovable</h3>
863<p>This property holds whether the dock windows are movable.
864<p>If TRUE (the default), the user will be able to move movable dock
865windows from one QMainWindow dock area to another, including the
866<tt>TearOff</tt> area (i.e. where the dock window floats freely as a
867window in its own right), and the <a href="qt.html#Dock-enum">Minimized</a> area (where only
868the dock window's handle is shown below the menu bar). Moveable
869dock windows can also be moved within QMainWindow dock areas, i.e.
870to rearrange them within a dock area.
871<p> If FALSE the user will not be able to move any dock windows.
872<p> By default dock windows are moved transparently (i.e. only an
873outline rectangle is shown during the drag), but this setting can
874be changed with <a href="#setOpaqueMoving">setOpaqueMoving</a>().
875<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>() and <a href="#opaqueMoving-prop">opaqueMoving</a>.
876
877<p>Set this property's value with <a href="#setDockWindowsMovable">setDockWindowsMovable</a>() and get this property's value with <a href="#dockWindowsMovable">dockWindowsMovable</a>().
878<h3 class=fn>bool <a name="opaqueMoving-prop"></a>opaqueMoving</h3>
879<p>This property holds whether dock windows are moved opaquely.
880<p>If TRUE the dock windows of the main window are shown opaquely
881(i.e. it shows the toolbar as it looks when docked) whilst it is
882being moved. If FALSE (the default) they are shown transparently,
883(i.e. as an outline rectangle).
884<p> <b>Warning:</b> Opaque moving of toolbars and dockwindows is known to
885have several problems. We recommend avoiding the use of this
886feature for the time being. We intend fixing the problems in a
887future release.
888
889<p>Set this property's value with <a href="#setOpaqueMoving">setOpaqueMoving</a>() and get this property's value with <a href="#opaqueMoving">opaqueMoving</a>().
890<h3 class=fn>bool <a name="rightJustification-prop"></a>rightJustification</h3>
891<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
892<p> <p>This property holds whether the main window right-justifies its dock windows.
893<p>If disabled (the default), stretchable dock windows are expanded,
894and non-stretchable dock windows are given the minimum space they
895need. Since most dock windows are not stretchable, this usually
896results in an unjustified right edge (or unjustified bottom edge
897for a vertical dock area). If enabled, the main window will
898right-justify its dock windows.
899<p> <p>See also <a href="qdockwindow.html#setVerticalStretchable">QDockWindow::setVerticalStretchable</a>() and <a href="qdockwindow.html#setHorizontalStretchable">QDockWindow::setHorizontalStretchable</a>().
900
901<p>Set this property's value with <a href="#setRightJustification">setRightJustification</a>() and get this property's value with <a href="#rightJustification">rightJustification</a>().
902<h3 class=fn>bool <a name="usesBigPixmaps-prop"></a>usesBigPixmaps</h3>
903<p>This property holds whether big pixmaps are enabled.
904<p>If FALSE (the default), the tool buttons will use small pixmaps;
905otherwise big pixmaps will be used.
906<p> Tool buttons and other widgets that wish to respond to this
907setting are responsible for reading the correct state on startup,
908and for connecting to the main window's widget's
909<a href="#pixmapSizeChanged">pixmapSizeChanged</a>() signal.
910
911<p>Set this property's value with <a href="#setUsesBigPixmaps">setUsesBigPixmaps</a>() and get this property's value with <a href="#usesBigPixmaps">usesBigPixmaps</a>().
912<h3 class=fn>bool <a name="usesTextLabel-prop"></a>usesTextLabel</h3>
913<p>This property holds whether text labels for toolbar buttons are enabled.
914<p>If disabled (the default), the tool buttons will not use text
915labels. If enabled, text labels will be used.
916<p> Tool buttons and other widgets that wish to respond to this
917setting are responsible for reading the correct state on startup,
918and for connecting to the main window's widget's
919<a href="#usesTextLabelChanged">usesTextLabelChanged</a>() signal.
920<p> <p>See also <a href="qtoolbutton.html#usesTextLabel-prop">QToolButton::usesTextLabel</a>.
921
922<p>Set this property's value with <a href="#setUsesTextLabel">setUsesTextLabel</a>() and get this property's value with <a href="#usesTextLabel">usesTextLabel</a>().
923<hr><h2>Related Functions</h2>
924<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qtextstream.html">QTextStream</a>&nbsp;&amp;&nbsp;ts, const&nbsp;<a href="qmainwindow.html">QMainWindow</a>&nbsp;&amp;&nbsp;mainWindow )
925</h3>
926
927<p> Writes the layout (sizes and positions) of the dock windows in the
928dock areas of the QMainWindow <em>mainWindow</em>, including <a href="qt.html#Dock-enum">Minimized</a> and <a href="qt.html#Dock-enum">TornOff</a> dock windows, to the text stream <em>ts</em>.
929<p> This can be used, for example, in conjunction with <a href="qsettings.html">QSettings</a> to
930save the user's layout when the \mainWindow receives a closeEvent.
931<p> <p>See also <a href="#operator-gt-gt">operator&gt;&gt;</a>() and <a href="qwidget.html#closeEvent">closeEvent</a>().
932
933<h3 class=fn><a href="qtextstream.html">QTextStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qtextstream.html">QTextStream</a>&nbsp;&amp;&nbsp;ts, <a href="qmainwindow.html">QMainWindow</a>&nbsp;&amp;&nbsp;mainWindow )
934</h3>
935
936<p> Reads the layout (sizes and positions) of the dock windows in the
937dock areas of the QMainWindow <em>mainWindow</em> from the text stream,
938<em>ts</em>, including <a href="qt.html#Dock-enum">Minimized</a> and <a href="qt.html#Dock-enum">TornOff</a> dock windows.
939Restores the dock windows and dock areas to these sizes and
940positions. The layout information must be in the format produced
941by <a href="#operator-lt-lt">operator&lt;&lt;</a>().
942<p> This can be used, for example, in conjunction with <a href="qsettings.html">QSettings</a> to
943restore the user's layout.
944<p> <p>See also <a href="#operator-lt-lt">operator&lt;&lt;</a>().
945
946<!-- eof -->
947<hr><p>
948This file is part of the <a href="index.html">Qt toolkit</a>.
949Copyright &copy; 1995-2007
950<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
951<table width=100% cellspacing=0 border=0><tr>
952<td>Copyright &copy; 2007
953<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
954<td align=right><div align=right>Qt 3.3.8</div>
955</table></div></address></body>
956</html>
Note: See TracBrowser for help on using the repository browser.