You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qt3/doc/html/qmainwindow.html

957 lines
61 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qmainwindow.cpp:506 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QMainWindow Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<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>
<p>The QMainWindow class provides a main application window,
with a menu bar, dock windows (e.g. for toolbars), and a status
bar.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qmainwindow-h.html">qmainwindow.h</a>&gt;</tt>
<p>Inherits <a href="qwidget.html">QWidget</a>.
<p><a href="qmainwindow-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<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>
<li class=fn><a href="#~QMainWindow"><b>~QMainWindow</b></a> ()</li>
<li class=fn>QMenuBar * <a href="#menuBar"><b>menuBar</b></a> () const</li>
<li class=fn>QStatusBar * <a href="#statusBar"><b>statusBar</b></a> () const</li>
<li class=fn>QToolTipGroup * <a href="#toolTipGroup"><b>toolTipGroup</b></a> () const</li>
<li class=fn>virtual void <a href="#setCentralWidget"><b>setCentralWidget</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
<li class=fn>QWidget * <a href="#centralWidget"><b>centralWidget</b></a> () const</li>
<li class=fn>virtual void <a href="#setDockEnabled"><b>setDockEnabled</b></a> ( Dock&nbsp;dock, bool&nbsp;enable )</li>
<li class=fn>bool <a href="#isDockEnabled"><b>isDockEnabled</b></a> ( Dock&nbsp;dock ) const</li>
<li class=fn>bool <a href="#isDockEnabled-2"><b>isDockEnabled</b></a> ( QDockArea&nbsp;*&nbsp;area ) const</li>
<li class=fn>virtual void <a href="#setDockEnabled-2"><b>setDockEnabled</b></a> ( QDockWindow&nbsp;*&nbsp;dw, Dock&nbsp;dock, bool&nbsp;enable )</li>
<li class=fn>bool <a href="#isDockEnabled-3"><b>isDockEnabled</b></a> ( QDockWindow&nbsp;*&nbsp;tb, Dock&nbsp;dock ) const</li>
<li class=fn>bool <a href="#isDockEnabled-4"><b>isDockEnabled</b></a> ( QDockWindow&nbsp;*&nbsp;dw, QDockArea&nbsp;*&nbsp;area ) const</li>
<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>
<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>
<li class=fn>virtual void <a href="#moveDockWindow"><b>moveDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow, Dock&nbsp;edge = DockTop )</li>
<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>
<li class=fn>virtual void <a href="#removeDockWindow"><b>removeDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow )</li>
<li class=fn>bool rightJustification () const &nbsp;<em>(obsolete)</em></li>
<li class=fn>bool <a href="#usesBigPixmaps"><b>usesBigPixmaps</b></a> () const</li>
<li class=fn>bool <a href="#usesTextLabel"><b>usesTextLabel</b></a> () const</li>
<li class=fn>bool <a href="#dockWindowsMovable"><b>dockWindowsMovable</b></a> () const</li>
<li class=fn>bool <a href="#opaqueMoving"><b>opaqueMoving</b></a> () const</li>
<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>
<li class=fn>QPtrList&lt;QDockWindow&gt; <a href="#dockWindows"><b>dockWindows</b></a> ( Dock&nbsp;dock ) const</li>
<li class=fn>QPtrList&lt;QDockWindow&gt; <a href="#dockWindows-2"><b>dockWindows</b></a> () const</li>
<li class=fn>void <a href="#lineUpDockWindows"><b>lineUpDockWindows</b></a> ( bool&nbsp;keepNewLines = FALSE )</li>
<li class=fn>bool <a href="#isDockMenuEnabled"><b>isDockMenuEnabled</b></a> () const</li>
<li class=fn>bool <a href="#hasDockWindow"><b>hasDockWindow</b></a> ( QDockWindow&nbsp;*&nbsp;dw )</li>
<li class=fn>void addToolBar ( QDockWindow *, Dock = DockTop, bool&nbsp;newLine = FALSE ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>void addToolBar ( QDockWindow *, const&nbsp;QString&nbsp;&amp;&nbsp;label, Dock = DockTop, bool&nbsp;newLine = FALSE ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>void moveToolBar ( QDockWindow *, Dock = DockTop ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>void moveToolBar ( QDockWindow *, Dock, bool&nbsp;nl, int&nbsp;index, int&nbsp;extraOffset = -1 ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>void removeToolBar ( QDockWindow * ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>bool toolBarsMovable () const &nbsp;<em>(obsolete)</em></li>
<li class=fn>QPtrList&lt;QToolBar&gt; <a href="#toolBars"><b>toolBars</b></a> ( Dock&nbsp;dock ) const</li>
<li class=fn>void lineUpToolBars ( bool&nbsp;keepNewLines = FALSE ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>QDockArea * <a href="#leftDock"><b>leftDock</b></a> () const</li>
<li class=fn>QDockArea * <a href="#rightDock"><b>rightDock</b></a> () const</li>
<li class=fn>QDockArea * <a href="#topDock"><b>topDock</b></a> () const</li>
<li class=fn>QDockArea * <a href="#bottomDock"><b>bottomDock</b></a> () const</li>
<li class=fn>virtual bool <a href="#isCustomizable"><b>isCustomizable</b></a> () const</li>
<li class=fn>bool <a href="#appropriate"><b>appropriate</b></a> ( QDockWindow&nbsp;*&nbsp;dw ) const</li>
<li class=fn>enum <a href="#DockWindows-enum"><b>DockWindows</b></a> { OnlyToolBars, NoToolBars, AllDockWindows }</li>
<li class=fn>QPopupMenu * <a href="#createDockWindowMenu"><b>createDockWindowMenu</b></a> ( DockWindows&nbsp;dockWindows = AllDockWindows ) const</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>virtual void setRightJustification ( bool ) &nbsp;<em>(obsolete)</em></li>
<li class=fn>virtual void <a href="#setUsesBigPixmaps"><b>setUsesBigPixmaps</b></a> ( bool )</li>
<li class=fn>virtual void <a href="#setUsesTextLabel"><b>setUsesTextLabel</b></a> ( bool )</li>
<li class=fn>virtual void <a href="#setDockWindowsMovable"><b>setDockWindowsMovable</b></a> ( bool )</li>
<li class=fn>virtual void <a href="#setOpaqueMoving"><b>setOpaqueMoving</b></a> ( bool )</li>
<li class=fn>virtual void <a href="#setDockMenuEnabled"><b>setDockMenuEnabled</b></a> ( bool&nbsp;b )</li>
<li class=fn>virtual void <a href="#whatsThis"><b>whatsThis</b></a> ()</li>
<li class=fn>virtual void <a href="#setAppropriate"><b>setAppropriate</b></a> ( QDockWindow&nbsp;*&nbsp;dw, bool&nbsp;a )</li>
<li class=fn>virtual void <a href="#customize"><b>customize</b></a> ()</li>
<li class=fn>void setToolBarsMovable ( bool ) &nbsp;<em>(obsolete)</em></li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#pixmapSizeChanged"><b>pixmapSizeChanged</b></a> ( bool )</li>
<li class=fn>void <a href="#usesTextLabelChanged"><b>usesTextLabelChanged</b></a> ( bool )</li>
<li class=fn>void <a href="#dockWindowPositionChanged"><b>dockWindowPositionChanged</b></a> ( QDockWindow&nbsp;*&nbsp;dockWindow )</li>
<li class=fn>void toolBarPositionChanged ( QToolBar * ) &nbsp;<em>(obsolete)</em></li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>bool <a href="#dockWindowsMovable-prop"><b>dockWindowsMovable</b></a>&nbsp;- whether the dock windows are movable</li>
<li class=fn>bool <a href="#opaqueMoving-prop"><b>opaqueMoving</b></a>&nbsp;- whether dock windows are moved opaquely</li>
<li class=fn>bool rightJustification&nbsp;- whether the main window right-justifies its dock windows &nbsp;<em>(obsolete)</em></li>
<li class=fn>bool <a href="#usesBigPixmaps-prop"><b>usesBigPixmaps</b></a>&nbsp;- whether big pixmaps are enabled</li>
<li class=fn>bool <a href="#usesTextLabel-prop"><b>usesTextLabel</b></a>&nbsp;- whether text labels for toolbar buttons are enabled</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#childEvent"><b>childEvent</b></a> ( QChildEvent&nbsp;*&nbsp;e )</li>
</ul>
<h2>Protected Slots</h2>
<ul>
<li class=fn>virtual void <a href="#setUpLayout"><b>setUpLayout</b></a> ()</li>
<li class=fn>virtual bool <a href="#showDockMenu"><b>showDockMenu</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;globalPos )</li>
<li class=fn>void <a href="#menuAboutToShow"><b>menuAboutToShow</b></a> ()</li>
</ul>
<h2>Related Functions</h2>
<ul>
<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>
<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>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The QMainWindow class provides a main application window,
with a menu bar, dock windows (e.g. for toolbars), and a status
bar.
<p>
<p> Main windows are most often used to provide menus, toolbars and a
status bar around a large central widget, such as a text edit,
drawing canvas or <a href="qworkspace.html">QWorkspace</a> (for MDI applications). QMainWindow
is usually subclassed since this makes it easier to encapsulate
the central widget, menus and toolbars as well as the window's
state. Subclassing makes it possible to create the slots that are
called when the user clicks menu items or toolbar buttons. You can
also create main windows using <a href="designer-manual.html">Qt
Designer</a>. We'll briefly review adding menu items and
toolbar buttons then describe the facilities of QMainWindow
itself.
<p> <pre>
QMainWindow *mw = new QMainWindow;
<a href="qtextedit.html">QTextEdit</a> *edit = new <a href="qtextedit.html">QTextEdit</a>( mw, "editor" );
edit-&gt;<a href="qwidget.html#setFocus">setFocus</a>();
mw-&gt;<a href="qwidget.html#setCaption">setCaption</a>( "Main Window" );
mw-&gt;<a href="#setCentralWidget">setCentralWidget</a>( edit );
mw-&gt;<a href="qwidget.html#show">show</a>();
</pre>
<p> QMainWindows may be created in their own right as shown above.
The central widget is set with <a href="#setCentralWidget">setCentralWidget</a>(). Popup menus can
be added to the default menu bar, widgets can be added to the
status bar, toolbars and dock windows can be added to any of the
dock areas.
<p>
<pre> ApplicationWindow *mw = new ApplicationWindow();
mw-&gt;<a href="qwidget.html#setCaption">setCaption</a>( "Qt Example - Application" );
<a name="x2115"></a> mw-&gt;<a href="qwidget.html#show">show</a>();
</pre>
<p> In the extract above ApplicationWindow is a subclass of
QMainWindow that we must write for ourselves; this is the usual
approach to using QMainWindow. (The source for the extracts in
this 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> )
<p> When subclassing we add the menu items and toolbars in the
subclass's constructor. If we've created a QMainWindow instance
directly we can add menu items and toolbars just as easily by
passing the QMainWindow instance as the parent instead of the <em>this</em> pointer.
<p>
<pre> <a href="qpopupmenu.html">QPopupMenu</a> * help = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
<a href="#menuBar">menuBar</a>()-&gt;insertItem( "&amp;Help", help );
help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;About", this, SLOT(about()), Key_F1 );
</pre>
<p> Here we've added a new menu with one menu item. The menu has been
inserted into the menu bar that QMainWindow provides by default
and which is accessible through the <a href="#menuBar">menuBar</a>() function. The slot
will be called when the menu item is clicked.
<p>
<pre> <a href="qtoolbar.html">QToolBar</a> * fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );
fileTools-&gt;<a href="qtoolbar.html#setLabel">setLabel</a>( "File Operations" );
</pre><pre> QToolButton * fileOpen
= new <a href="qtoolbutton.html">QToolButton</a>( openIcon, "Open File", <a href="qstring.html#QString-null">QString::null</a>,
this, SLOT(choose()), fileTools, "open file" );
</pre>
<p> This extract shows the creation of a toolbar with one toolbar
button. QMainWindow supplies four dock areas for toolbars. When a
toolbar is created as a child of a QMainWindow (or derived class)
instance it will be placed in a dock area (the <a href="qt.html#Dock-enum">Top</a> dock area by
default). The slot will be called when the toolbar button is
clicked. Any dock window can be added to a dock area either using
<a href="#addDockWindow">addDockWindow</a>(), or by creating a dock window with the QMainWindow
as the parent.
<p>
<pre> e = new <a href="qtextedit.html">QTextEdit</a>( this, "editor" );
e-&gt;<a href="qwidget.html#setFocus">setFocus</a>();
<a href="#setCentralWidget">setCentralWidget</a>( e );
<a href="#statusBar">statusBar</a>()-&gt;message( "Ready", 2000 );
</pre>
<p> Having created the menus and toolbar we create an instance of the
large central widget, give it the focus and set it as the main
window's central widget. In the example we've also set the status
bar, accessed via the <a href="#statusBar">statusBar</a>() function, to an initial message
which will be displayed for two seconds. Note that you can add
additional widgets to the status bar, for example labels, to show
further status information. See the <a href="qstatusbar.html">QStatusBar</a> documentation for
details, particularly the addWidget() function.
<p> Often we want to synchronize a toolbar button with a menu item.
For example, if the user clicks a 'bold' toolbar button we want
the 'bold' menu item to be checked. This synchronization can be
achieved automatically by creating actions and adding the actions
to the toolbar and menu.
<p>
<pre> <a href="qaction.html">QAction</a> * fileOpenAction;
</pre><pre> fileOpenAction = new <a href="qaction.html">QAction</a>( QPixmap( fileopen ), "&amp;Open...",
CTRL+Key_O, this, "open" );
<a href="qobject.html#connect">connect</a>( fileOpenAction, SIGNAL( <a href="qaction.html#activated">activated</a>() ) , this, SLOT( choose() ) );
</pre>
<p> Here we create an action with an icon which will be used in any
menu and toolbar that the action is added to. We've also given the
action a menu name, '&amp;Open', and a keyboard shortcut. The
connection that we have made will be used when the user clicks
either the menu item <em>or</em> the toolbar button.
<p>
<pre> <a href="qpopupmenu.html">QPopupMenu</a> * file = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
<a href="#menuBar">menuBar</a>()-&gt;insertItem( "&amp;File", file );
</pre><pre> fileOpenAction-&gt;<a href="qaction.html#addTo">addTo</a>( file );
</pre>
<p> The extract above shows the creation of a popup menu. We add the
menu to the QMainWindow's menu bar and add our action.
<p>
<pre> <a href="qtoolbar.html">QToolBar</a> * fileTools = new <a href="qtoolbar.html">QToolBar</a>( this, "file operations" );
fileTools-&gt;<a href="qtoolbar.html#setLabel">setLabel</a>( "File Operations" );
fileOpenAction-&gt;<a href="qaction.html#addTo">addTo</a>( fileTools );
</pre>
<p> Here we create a new toolbar as a child of the QMainWindow and add
our action to the toolbar.
<p> We'll now explore the functionality offered by QMainWindow.
<p> The main window will take care of the dock areas, and the geometry
of the central widget, but all other aspects of the central widget
are left to you. QMainWindow automatically detects the creation of
a menu bar or status bar if you specify the QMainWindow as parent,
or you can use the provided <a href="#menuBar">menuBar</a>() and <a href="#statusBar">statusBar</a>() functions.
The functions menuBar() and statusBar() create a suitable widget
if one doesn't exist, and update the window's layout to make
space.
<p> QMainWindow provides a <a href="qtooltipgroup.html">QToolTipGroup</a> connected to the status bar.
The function <a href="#toolTipGroup">toolTipGroup</a>() provides access to the default
QToolTipGroup. It isn't possible to set a different tool tip
group.
<p> New dock windows and toolbars can be added to a QMainWindow using
<a href="#addDockWindow">addDockWindow</a>(). Dock windows can be moved using <a href="#moveDockWindow">moveDockWindow</a>()
and removed with <a href="#removeDockWindow">removeDockWindow</a>(). QMainWindow allows default
dock 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
enable and disable docking areas for dock windows. When adding or
moving dock windows you can specify their 'edge' (dock area). The
currently 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
areas. Note that the *ToolBar functions are included for backward
compatibility; all new code should use the *DockWindow functions.
QToolbar is a subclass of <a href="qdockwindow.html">QDockWindow</a> so all functions that work
with dock windows work on toolbars in the same way.
<p> <a name="dwm"></a>
If the user clicks the close button, then the dock window is
hidden. A dock window can be hidden or unhidden by the user by
right clicking a dock area and clicking the name of the relevant
dock window on the pop up dock window menu. This menu lists the
names of every dock window; visible dock windows have a tick
beside their names. The dock window menu is created automatically
as required by <a href="#createDockWindowMenu">createDockWindowMenu</a>(). Since it may not always be
appropriate for a dock window to appear on this menu the
<a href="#setAppropriate">setAppropriate</a>() function is used to inform the main window
whether or not the dock window menu should include a particular
dock window. Double clicking a dock window handle (usually on the
left-hand side of the dock window) undocks (floats) the dock
window. Double clicking a floating dock window's titlebar will
dock the floating dock window. (See also
<a href="#DockWindows-enum">QMainWindow::DockWindows</a>.)
<p> Some functions change the appearance of a QMainWindow globally:
<ul>
<li> <a href="qdockwindow.html#setHorizontalStretchable">QDockWindow::setHorizontalStretchable</a>() and
<a href="qdockwindow.html#setVerticalStretchable">QDockWindow::setVerticalStretchable</a>() are used to make specific dock
windows or toolbars stretchable.
<li> <a href="#setUsesBigPixmaps">setUsesBigPixmaps</a>() is used to set whether tool buttons should
draw small or large pixmaps (see <a href="qiconset.html">QIconSet</a> for more information).
<li> <a href="#setUsesTextLabel">setUsesTextLabel</a>() is used to set whether tool buttons
should display a textual label in addition to pixmaps
(see <a href="qtoolbutton.html">QToolButton</a> for more information).
</ul>
<p> The user can drag dock windows into any enabled docking area. Dock
windows can also be dragged <em>within</em> a docking area, for example
to rearrange the order of some toolbars. Dock windows can also be
dragged outside any docking area (undocked or 'floated'). Being
able to drag dock windows can be enabled (the default) and
disabled using <a href="#setDockWindowsMovable">setDockWindowsMovable</a>().
<p> The <a href="qt.html#Dock-enum">Minimized</a> edge is a hidden dock area. If this dock area is
enabled the user can hide (minimize) a dock window or show (restore)
a minimized dock window by clicking the dock window handle. If the
user hovers the mouse cursor over one of the handles, the caption of
the dock window is displayed in a tool tip (see
<a href="qwidget.html#caption">QDockWindow::caption</a>() or <a href="qtoolbar.html#label">QToolBar::label</a>()), so if you enable the
<a href="qt.html#Dock-enum">Minimized</a> dock area, it is best to specify a meaningful caption
or label for each dock window. To minimize a dock window
programmatically use <a href="#moveDockWindow">moveDockWindow</a>() with an edge of <a href="qt.html#Dock-enum">Minimized</a>.
<p> Dock windows are moved transparently by default, i.e. during the
drag an outline rectangle is drawn on the screen representing the
position of the dock window as it moves. If you want the dock
window to be shown normally whilst it is moved use
<a href="#setOpaqueMoving">setOpaqueMoving</a>().
<p> The location of a dock window, i.e. its dock area and position
within the dock area, can be determined by calling <a href="#getLocation">getLocation</a>().
Movable dock windows can be lined up to minimize wasted space with
<a href="#lineUpDockWindows">lineUpDockWindows</a>(). Pointers to the dock areas are available from
<a href="#topDock">topDock</a>(), <a href="#leftDock">leftDock</a>(), <a href="#rightDock">rightDock</a>() and <a href="#bottomDock">bottomDock</a>(). A customize
menu item is added to the pop up dock window menu if
<a href="#isCustomizable">isCustomizable</a>() returns TRUE; it returns FALSE by default.
Reimplement isCustomizable() and <a href="#customize">customize</a>() if you want to offer
this extra menu item, for example, to allow the user to change
settings relating to the main window and its toolbars and dock
windows.
<p> The main window's menu bar is fixed (at the top) by default. If
you want a movable menu bar, create a <a href="qmenubar.html">QMenuBar</a> as a stretchable
widget inside its own movable dock window and restrict this dock
window to only live within the <a href="qt.html#Dock-enum">Top</a> or <a href="qt.html#Dock-enum">Bottom</a> dock:
<p> <pre>
<a href="qtoolbar.html">QToolBar</a> *tb = new <a href="qtoolbar.html">QToolBar</a>( this );
<a href="#addDockWindow">addDockWindow</a>( tb, tr( "Menubar" ), Top, FALSE );
<a href="qmenubar.html">QMenuBar</a> *mb = new <a href="qmenubar.html">QMenuBar</a>( tb );
mb-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>( QFrame::NoFrame );
tb-&gt;<a href="qtoolbar.html#setStretchableWidget">setStretchableWidget</a>( mb );
<a href="#setDockEnabled">setDockEnabled</a>( tb, Left, FALSE );
<a href="#setDockEnabled">setDockEnabled</a>( tb, Right, FALSE );
</pre>
<p> An application with multiple dock windows can choose to save the
current dock window layout in order to restore it later, e.g. in
the next session. You can do this by using the streaming operators
for QMainWindow.
<p> To save the layout and positions of all the dock windows do this:
<p> <pre>
<a href="qfile.html">QFile</a> file( filename );
if ( file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_WriteOnly</a> ) ) {
<a href="qtextstream.html">QTextStream</a> stream( &amp;file );
stream &lt;&lt; *mainWindow;
file.<a href="qfile.html#close">close</a>();
}
</pre>
<p> To restore the dock window positions and sizes (normally when the
application is next started), do following:
<p> <pre>
<a href="qfile.html">QFile</a> file( filename );
if ( file.<a href="qfile.html#open">open</a>( <a href="qfile.html#open">IO_ReadOnly</a> ) ) {
<a href="qtextstream.html">QTextStream</a> stream( &amp;file );
stream &gt;&gt; *mainWindow;
file.<a href="qfile.html#close">close</a>();
}
</pre>
<p> The <a href="qsettings.html">QSettings</a> class can be used in conjunction with the streaming
operators to store the application's settings.
<p> QMainWindow's management of dock windows and toolbars is done
transparently behind-the-scenes by <a href="qdockarea.html">QDockArea</a>.
<p> For multi-document interfaces (MDI), use a <a href="qworkspace.html">QWorkspace</a> as the
central widget.
<p> Adding dock windows, e.g. toolbars, to QMainWindow's dock areas is
straightforward. If the supplied dock areas are not sufficient for
your application we suggest that you create a <a href="qwidget.html">QWidget</a> subclass and
add your own dock areas (see <a href="qdockarea.html">QDockArea</a>) to the subclass since
QMainWindow provides functionality specific to the standard dock
areas it provides.
<p> <img src=qmainwindow-m.png> <img src=qmainwindow-w.png>
<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>.
<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="DockWindows-enum"></a>QMainWindow::DockWindows</h3>
<p> Right-clicking a dock area will pop-up the dock window menu
(<a href="#createDockWindowMenu">createDockWindowMenu</a>() is called automatically). When called in
code you can specify what items should appear on the menu with
this enum.
<ul>
<li><tt>QMainWindow::OnlyToolBars</tt> - The menu will list all the toolbars, but not
any other dock windows.
<li><tt>QMainWindow::NoToolBars</tt> - The menu will list dock windows but not
toolbars.
<li><tt>QMainWindow::AllDockWindows</tt> - The menu will list all toolbars and other
dock windows. (This is the default.)
</ul>
<hr><h2>Member Function Documentation</h2>
<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 )
</h3>
Constructs an empty main window. The <em>parent</em>, <em>name</em> and widget
flags <em>f</em>, are passed on to the <a href="qwidget.html">QWidget</a> constructor.
<p> By default, the widget flags are set to <a href="qt.html#WidgetFlags-enum">WType_TopLevel</a> rather
than 0 as they are with QWidget. If you don't want your
QMainWindow to be a top level widget then you will need to set <em>f</em> to 0.
<h3 class=fn><a name="~QMainWindow"></a>QMainWindow::~QMainWindow ()
</h3>
Destroys the object and frees any allocated resources.
<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>
</h3>
Adds <em>dockWindow</em> to the <em>edge</em> dock area.
<p> If <em>newLine</em> is FALSE (the default) then the <em>dockWindow</em> is
added at the end of the <em>edge</em>. For vertical edges the end is at
the bottom, for horizontal edges (including <a href="qt.html#Dock-enum">Minimized</a>) the end
is at the right. If <em>newLine</em> is TRUE a new line of dock windows
is started with <em>dockWindow</em> as the first (left-most and
top-most) dock window.
<p> If <em>dockWindow</em> is managed by another main window, it is first
removed from that window.
<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>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Adds <em>dockWindow</em> to the dock area with label <em>label</em>.
<p> If <em>newLine</em> is FALSE (the default) the <em>dockWindow</em> is added at
the end of the <em>edge</em>. For vertical edges the end is at the
bottom, for horizontal edges (including <a href="qt.html#Dock-enum">Minimized</a>) the end is
at the right. If <em>newLine</em> is TRUE a new line of dock windows is
started with <em>dockWindow</em> as the first (left-most and top-most)
dock window.
<p> If <em>dockWindow</em> is managed by another main window, it is first
removed from that window.
<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 )
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<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 )
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn>bool <a name="appropriate"></a>QMainWindow::appropriate ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw ) const
</h3>
Returns TRUE if it is appropriate to include a menu item for the
<em>dw</em> dock window in the dock window menu; otherwise returns
FALSE.
<p> The user is able to change the state (show or hide) a dock window
that has a menu item by clicking the item.
<p> Call <a href="#setAppropriate">setAppropriate</a>() to indicate whether or not a particular dock
window should appear on the popup menu.
<p> <p>See also <a href="#setAppropriate">setAppropriate</a>().
<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="bottomDock"></a>QMainWindow::bottomDock () const
</h3>
Returns a pointer the <a href="qt.html#Dock-enum">Bottom</a> dock area
<p> <p>See also <a href="#topDock">topDock</a>(), <a href="#leftDock">leftDock</a>(), and <a href="#rightDock">rightDock</a>().
<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="centralWidget"></a>QMainWindow::centralWidget () const
</h3>
Returns a pointer to the main window's central widget.
<p> The central widget is surrounded by the left, top, right and
bottom dock areas. The menu bar is above the top dock area.
<p> <p>See also <a href="#setCentralWidget">setCentralWidget</a>().
<p>Example: <a href="qfd-example.html#x2013">qfd/qfd.cpp</a>.
<h3 class=fn>void <a name="childEvent"></a>QMainWindow::childEvent ( <a href="qchildevent.html">QChildEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
</h3>
Monitors events, recieved in <em>e</em>, to ensure the layout is updated.
<p>Reimplemented from <a href="qobject.html#childEvent">QObject</a>.
<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
</h3>
Creates 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
<em>dockWindows</em> is <a href="#DockWindows-enum">AllDockWindows</a> - the default).
<p> This function is called internally when necessary, e.g. when the
user right clicks a dock area (providing <a href="#isDockMenuEnabled">isDockMenuEnabled</a>()
returns TRUE).
<p> The menu items representing the toolbars and dock windows are
checkable. The visible dock windows are checked and the hidden
dock windows are unchecked. The user can click a menu item to
change its state (show or hide the dock window).
<p> The list and the state are always kept up-to-date.
<p> Toolbars and dock windows which are not appropriate in the current
context (see <a href="#setAppropriate">setAppropriate</a>()) are not listed in the menu.
<p> The menu also has a menu item for lining up the dock windows.
<p> If <a href="#isCustomizable">isCustomizable</a>() returns TRUE, a Customize menu item is added
to the menu, which if clicked will call <a href="#customize">customize</a>(). The
isCustomizable() function we provide returns FALSE and customize()
does nothing, so they must be reimplemented in a subclass to be
useful.
<h3 class=fn>void <a name="customize"></a>QMainWindow::customize ()<tt> [virtual slot]</tt>
</h3>
This function is called when the user clicks the Customize menu
item on the dock window menu.
<p> The customize menu item will only appear if <a href="#isCustomizable">isCustomizable</a>()
returns TRUE (it returns FALSE by default).
<p> The function is intended, for example, to provide the user with a
means of telling the application that they wish to customize the
main window, dock windows or dock areas.
<p> The default implementation does nothing and the Customize menu
item is not shown on the right-click menu by default. If you want
the item to appear then reimplement isCustomizable() to return
TRUE, and reimplement this function to do whatever you want.
<p> <p>See also <a href="#isCustomizable">isCustomizable</a>().
<h3 class=fn>void <a name="dockWindowPositionChanged"></a>QMainWindow::dockWindowPositionChanged ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow )<tt> [signal]</tt>
</h3>
<p> This signal is emitted when the <em>dockWindow</em> has changed its
position. A change in position occurs when a dock window is moved
within its dock area or moved to another dock area (including the
<a href="qt.html#Dock-enum">Minimized</a> and <tt>TearOff</tt> dock areas).
<p> <p>See also <a href="#getLocation">getLocation</a>().
<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
</h3>
Returns a list of all the dock windows which are in the <em>dock</em>
dock area, regardless of their state.
<p> For example, the <a href="qt.html#Dock-enum">DockTornOff</a> dock area may contain closed dock
windows but these are returned along with the visible dock
windows.
<h3 class=fn><a href="qptrlist.html">QPtrList</a>&lt;QDockWindow&gt; <a name="dockWindows-2"></a>QMainWindow::dockWindows () const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns the list of dock windows which belong to this main window,
regardless of which dock area they are in or what their state is,
(e.g. irrespective of whether they are visible or not).
<h3 class=fn>bool <a name="dockWindowsMovable"></a>QMainWindow::dockWindowsMovable () const
</h3><p>Returns TRUE if the dock windows are movable; otherwise returns FALSE.
See the <a href="qmainwindow.html#dockWindowsMovable-prop">"dockWindowsMovable"</a> property for details.
<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
</h3>
Finds the location of the dock window <em>dw</em>.
<p> If the <em>dw</em> dock window is found in the main window the function
returns TRUE and populates the <em>dock</em> variable with the dw's dock
area and the <em>index</em> with the dw's position within the dock area.
It also sets <em>nl</em> to TRUE if the <em>dw</em> begins a new line
(otherwise FALSE), and <em>extraOffset</em> with the dock window's offset.
<p> If the <em>dw</em> dock window is not found then the function returns
FALSE and the state of <em>dock</em>, <em>index</em>, <em>nl</em> and <em>extraOffset</em>
is undefined.
<p> If you want to save and restore dock window positions then use
<a href="#operator-gt-gt">operator&gt;&gt;</a>() and <a href="#operator-lt-lt">operator&lt;&lt;</a>().
<p> <p>See also <a href="#operator-gt-gt">operator&gt;&gt;</a>() and <a href="#operator-lt-lt">operator&lt;&lt;</a>().
<h3 class=fn>bool <a name="hasDockWindow"></a>QMainWindow::hasDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dw )
</h3>
Returns TRUE if <em>dw</em> is a dock window known to the main window;
otherwise returns FALSE.
<h3 class=fn>bool <a name="isCustomizable"></a>QMainWindow::isCustomizable () const<tt> [virtual]</tt>
</h3>
Returns TRUE if the dock area dock window menu includes the
Customize menu item (which calls <a href="#customize">customize</a>() when clicked).
Returns FALSE by default, i.e. the popup menu will not contain a
Customize menu item. You will need to reimplement this function
and set it to return TRUE if you wish the user to be able to see
the dock window menu.
<p> <p>See also <a href="#customize">customize</a>().
<h3 class=fn>bool <a name="isDockEnabled"></a>QMainWindow::isDockEnabled ( <a href="qt.html#Dock-enum">Dock</a>&nbsp;dock ) const
</h3>
Returns TRUE if the <em>dock</em> dock area is enabled, i.e. it can
accept user dragged dock windows; otherwise returns FALSE.
<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
<h3 class=fn>bool <a name="isDockEnabled-2"></a>QMainWindow::isDockEnabled ( <a href="qdockarea.html">QDockArea</a>&nbsp;*&nbsp;area ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if dock area <em>area</em> is enabled, i.e. it can accept
user dragged dock windows; otherwise returns FALSE.
<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
<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
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if dock area <em>dock</em> is enabled for the dock window
<em>tb</em>; otherwise returns FALSE.
<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
<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
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if dock area <em>area</em> is enabled for the dock window
<em>dw</em>; otherwise returns FALSE.
<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>().
<h3 class=fn>bool <a name="isDockMenuEnabled"></a>QMainWindow::isDockMenuEnabled () const
</h3>
Returns TRUE, if the dock window menu is enabled; otherwise
returns FALSE.
<p> The menu lists the (<a href="#appropriate">appropriate</a>()) dock windows (which may be
shown or hidden), and has a "Line Up Dock Windows" menu item. It
will also have a "Customize" menu item if <a href="#isCustomizable">isCustomizable</a>() returns
TRUE.
<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>().
<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="leftDock"></a>QMainWindow::leftDock () const
</h3>
Returns the <a href="qt.html#Dock-enum">Left</a> dock area
<p> <p>See also <a href="#rightDock">rightDock</a>(), <a href="#topDock">topDock</a>(), and <a href="#bottomDock">bottomDock</a>().
<h3 class=fn>void <a name="lineUpDockWindows"></a>QMainWindow::lineUpDockWindows ( bool&nbsp;keepNewLines = FALSE )
</h3>
This function will line up dock windows within the visible 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> and <a href="qt.html#Dock-enum">Bottom</a>) as compactly as
possible.
<p> If <em>keepNewLines</em> is TRUE, all dock windows stay on their
original lines. If <em>keepNewLines</em> is FALSE then newlines may be
removed to achieve the most compact layout possible.
<p> The method only works if <a href="#dockWindowsMovable">dockWindowsMovable</a>() returns TRUE.
<h3 class=fn>void <a name="lineUpToolBars"></a>QMainWindow::lineUpToolBars ( bool&nbsp;keepNewLines = FALSE )
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<h3 class=fn>void <a name="menuAboutToShow"></a>QMainWindow::menuAboutToShow ()<tt> [protected slot]</tt>
</h3>
This slot is called from the aboutToShow() signal of the default
dock menu of the mainwindow. The default implementation
initializes the menu with all dock windows and toolbars in this
slot.
<h3 class=fn><a href="qmenubar.html">QMenuBar</a>&nbsp;* <a name="menuBar"></a>QMainWindow::menuBar () const
</h3>
Returns the menu bar for this window.
<p> If there isn't one, then <a href="#menuBar">menuBar</a>() creates an empty menu bar.
<p> <p>See also <a href="#statusBar">statusBar</a>().
<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>
</h3>
Moves <em>dockWindow</em> to the end of the <em>edge</em>.
<p> For vertical edges the end is at the bottom, for horizontal edges
(including <a href="qt.html#Dock-enum">Minimized</a>) the end is at the right.
<p> If <em>dockWindow</em> is managed by another main window, it is first
removed from that window.
<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>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Moves <em>dockWindow</em> to position <em>index</em> within the <em>edge</em> dock
area.
<p> Any dock windows with positions <em>index</em> or higher have their
position number incremented and any of these on the same line are
moved right (down for vertical dock areas) to make room.
<p> If <em>nl</em> is TRUE, a new dock window line is created below the line
in which the moved dock window appears and the moved dock window,
with any others with higher positions on the same line, is moved
to this new line.
<p> The <em>extraOffset</em> is the space to put between the left side of
the dock area (top side for vertical dock areas) and the dock
window. (This is mostly used for restoring dock windows to the
positions the user has dragged them to.)
<p> If <em>dockWindow</em> is managed by another main window, it is first
removed from that window.
<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 )
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<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 )
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn>bool <a name="opaqueMoving"></a>QMainWindow::opaqueMoving () const
</h3><p>Returns TRUE if dock windows are moved opaquely; otherwise returns FALSE.
See the <a href="qmainwindow.html#opaqueMoving-prop">"opaqueMoving"</a> property for details.
<h3 class=fn>void <a name="pixmapSizeChanged"></a>QMainWindow::pixmapSizeChanged ( bool )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the <a href="#setUsesBigPixmaps">setUsesBigPixmaps</a>() is called
with a value different to the current setting. All widgets that
should respond to such changes, e.g. toolbar buttons, must connect
to this signal.
<h3 class=fn>void <a name="removeDockWindow"></a>QMainWindow::removeDockWindow ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;*&nbsp;dockWindow )<tt> [virtual]</tt>
</h3>
Removes <em>dockWindow</em> from the main window's docking area,
provided <em>dockWindow</em> is non-null and managed by this main
window.
<h3 class=fn>void <a name="removeToolBar"></a>QMainWindow::removeToolBar ( <a href="qdockwindow.html">QDockWindow</a>&nbsp;* )
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="rightDock"></a>QMainWindow::rightDock () const
</h3>
Returns the <a href="qt.html#Dock-enum">Right</a> dock area
<p> <p>See also <a href="#leftDock">leftDock</a>(), <a href="#topDock">topDock</a>(), and <a href="#bottomDock">bottomDock</a>().
<h3 class=fn>bool <a name="rightJustification"></a>QMainWindow::rightJustification () const
</h3><p>Returns TRUE if the main window right-justifies its dock windows; otherwise returns FALSE.
See the <a href="qmainwindow.html#rightJustification-prop">"rightJustification"</a> property for details.
<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>
</h3>
Use this function to control whether or not the <em>dw</em> dock
window's caption should appear as a menu item on the dock window
menu that lists the dock windows.
<p> If <em>a</em> is TRUE then the <em>dw</em> will appear as a menu item on the
dock window menu. The user is able to change the state (show or
hide) a dock window that has a menu item by clicking the item;
depending on the state of your application, this may or may not be
appropriate. If <em>a</em> is FALSE the <em>dw</em> will not appear on the
popup menu.
<p> <p>See also <a href="#showDockMenu">showDockMenu</a>(), <a href="#isCustomizable">isCustomizable</a>(), and <a href="#customize">customize</a>().
<h3 class=fn>void <a name="setCentralWidget"></a>QMainWindow::setCentralWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
</h3>
Sets the central widget for this main window to <em>w</em>.
<p> The central widget is surrounded by the left, top, right and
bottom dock areas. The menu bar is above the top dock area.
<p> <p>See also <a href="#centralWidget">centralWidget</a>().
<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>
</h3>
If <em>enable</em> is TRUE then users can dock windows in the <em>dock</em>
area. If <em>enable</em> is FALSE users cannot dock windows in the <em>dock</em> dock area.
<p> Users can dock (drag) dock windows into any enabled dock area.
<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>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> If <em>enable</em> is TRUE then users can dock the <em>dw</em> dock window in
the <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.
<p> In general users can dock (drag) dock windows into any enabled
dock area. Using this function particular dock areas can be
enabled (or disabled) as docking points for particular dock
windows.
<h3 class=fn>void <a name="setDockMenuEnabled"></a>QMainWindow::setDockMenuEnabled ( bool&nbsp;b )<tt> [virtual slot]</tt>
</h3>
If <em>b</em> is TRUE, then right clicking on a dock window or dock area
will pop up the dock window menu. If <em>b</em> is FALSE, right clicking
a dock window or dock area will not pop up the menu.
<p> The menu lists the (<a href="#appropriate">appropriate</a>()) dock windows (which may be
shown or hidden), and has a "Line Up Dock Windows" item. It will
also have a "Customize" menu item if <a href="#isCustomizable">isCustomizable</a>() returns
TRUE.
<p> <p>See also <a href="#lineUpDockWindows">lineUpDockWindows</a>() and <a href="#isDockMenuEnabled">isDockMenuEnabled</a>().
<h3 class=fn>void <a name="setDockWindowsMovable"></a>QMainWindow::setDockWindowsMovable ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets whether the dock windows are movable.
See the <a href="qmainwindow.html#dockWindowsMovable-prop">"dockWindowsMovable"</a> property for details.
<h3 class=fn>void <a name="setOpaqueMoving"></a>QMainWindow::setOpaqueMoving ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets whether dock windows are moved opaquely.
See the <a href="qmainwindow.html#opaqueMoving-prop">"opaqueMoving"</a> property for details.
<h3 class=fn>void <a name="setRightJustification"></a>QMainWindow::setRightJustification ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets whether the main window right-justifies its dock windows.
See the <a href="qmainwindow.html#rightJustification-prop">"rightJustification"</a> property for details.
<h3 class=fn>void <a name="setToolBarsMovable"></a>QMainWindow::setToolBarsMovable ( bool )<tt> [slot]</tt>
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<h3 class=fn>void <a name="setUpLayout"></a>QMainWindow::setUpLayout ()<tt> [virtual protected slot]</tt>
</h3>
Sets up the geometry management of the window. It is called
automatically when needed, so you shouldn't need to call it.
<h3 class=fn>void <a name="setUsesBigPixmaps"></a>QMainWindow::setUsesBigPixmaps ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets whether big pixmaps are enabled.
See the <a href="qmainwindow.html#usesBigPixmaps-prop">"usesBigPixmaps"</a> property for details.
<h3 class=fn>void <a name="setUsesTextLabel"></a>QMainWindow::setUsesTextLabel ( bool )<tt> [virtual slot]</tt>
</h3><p>Sets whether text labels for toolbar buttons are enabled.
See the <a href="qmainwindow.html#usesTextLabel-prop">"usesTextLabel"</a> property for details.
<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>
</h3>
Shows the dock menu at the position <em>globalPos</em>. The menu lists
the dock windows so that they can be shown (or hidden), lined up,
and possibly customized. Returns TRUE if the menu is shown;
otherwise returns FALSE.
<p> If you want a custom menu, reimplement this function. You can
create the menu from scratch or call <a href="#createDockWindowMenu">createDockWindowMenu</a>() and
modify the result.
<h3 class=fn><a href="qstatusbar.html">QStatusBar</a>&nbsp;* <a name="statusBar"></a>QMainWindow::statusBar () const
</h3>
Returns this main window's status bar. If there isn't one,
<a href="#statusBar">statusBar</a>() creates an empty status bar, and if necessary a tool
tip group too.
<p> <p>See also <a href="#menuBar">menuBar</a>() and <a href="#toolTipGroup">toolTipGroup</a>().
<p>Example: <a href="qfd-example.html#x2015">qfd/qfd.cpp</a>.
<h3 class=fn>void <a name="toolBarPositionChanged"></a>QMainWindow::toolBarPositionChanged ( <a href="qtoolbar.html">QToolBar</a>&nbsp;* )<tt> [signal]</tt>
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<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
</h3>
Returns a list of all the toolbars which are in the <em>dock</em> dock
area, regardless of their state.
<p> For example, the <a href="qt.html#Dock-enum">TornOff</a> dock area may contain closed toolbars
but these are returned along with the visible toolbars.
<p> <p>See also <a href="#dockWindows">dockWindows</a>().
<h3 class=fn>bool <a name="toolBarsMovable"></a>QMainWindow::toolBarsMovable () const
</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p>
<h3 class=fn><a href="qtooltipgroup.html">QToolTipGroup</a>&nbsp;* <a name="toolTipGroup"></a>QMainWindow::toolTipGroup () const
</h3>
Returns this main window's tool tip group. If there isn't one,
<a href="#toolTipGroup">toolTipGroup</a>() creates an empty tool tip group.
<p> <p>See also <a href="#menuBar">menuBar</a>() and <a href="#statusBar">statusBar</a>().
<h3 class=fn><a href="qdockarea.html">QDockArea</a>&nbsp;* <a name="topDock"></a>QMainWindow::topDock () const
</h3>
Returns the <a href="qt.html#Dock-enum">Top</a> dock area
<p> <p>See also <a href="#bottomDock">bottomDock</a>(), <a href="#leftDock">leftDock</a>(), and <a href="#rightDock">rightDock</a>().
<h3 class=fn>bool <a name="usesBigPixmaps"></a>QMainWindow::usesBigPixmaps () const
</h3><p>Returns TRUE if big pixmaps are enabled; otherwise returns FALSE.
See the <a href="qmainwindow.html#usesBigPixmaps-prop">"usesBigPixmaps"</a> property for details.
<h3 class=fn>bool <a name="usesTextLabel"></a>QMainWindow::usesTextLabel () const
</h3><p>Returns TRUE if text labels for toolbar buttons are enabled; otherwise returns FALSE.
See the <a href="qmainwindow.html#usesTextLabel-prop">"usesTextLabel"</a> property for details.
<h3 class=fn>void <a name="usesTextLabelChanged"></a>QMainWindow::usesTextLabelChanged ( bool )<tt> [signal]</tt>
</h3>
<p> This signal is emitted whenever the <a href="#setUsesTextLabel">setUsesTextLabel</a>() is called
with a value different to the current setting. All widgets that
should respond to such changes, e.g. toolbar buttons, must connect
to this signal.
<h3 class=fn>void <a name="whatsThis"></a>QMainWindow::whatsThis ()<tt> [virtual slot]</tt>
</h3>
Enters 'What's This?' mode and returns immediately.
<p> This is the same as <a href="qwhatsthis.html#enterWhatsThisMode">QWhatsThis::enterWhatsThisMode</a>(), but
implemented as a main window object's slot. This way it can easily
be used for popup menus, for example:
<p> <pre>
<a href="qpopupmenu.html">QPopupMenu</a> * help = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
help-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "What's &amp;This", this , SLOT(<a href="#whatsThis">whatsThis</a>()), SHIFT+Key_F1);
</pre>
<p> <p>See also <a href="qwhatsthis.html#enterWhatsThisMode">QWhatsThis::enterWhatsThisMode</a>().
<hr><h2>Property Documentation</h2>
<h3 class=fn>bool <a name="dockWindowsMovable-prop"></a>dockWindowsMovable</h3>
<p>This property holds whether the dock windows are movable.
<p>If TRUE (the default), the user will be able to move movable dock
windows from one QMainWindow dock area to another, including the
<tt>TearOff</tt> area (i.e. where the dock window floats freely as a
window in its own right), and the <a href="qt.html#Dock-enum">Minimized</a> area (where only
the dock window's handle is shown below the menu bar). Moveable
dock windows can also be moved within QMainWindow dock areas, i.e.
to rearrange them within a dock area.
<p> If FALSE the user will not be able to move any dock windows.
<p> By default dock windows are moved transparently (i.e. only an
outline rectangle is shown during the drag), but this setting can
be changed with <a href="#setOpaqueMoving">setOpaqueMoving</a>().
<p> <p>See also <a href="#setDockEnabled">setDockEnabled</a>() and <a href="#opaqueMoving-prop">opaqueMoving</a>.
<p>Set this property's value with <a href="#setDockWindowsMovable">setDockWindowsMovable</a>() and get this property's value with <a href="#dockWindowsMovable">dockWindowsMovable</a>().
<h3 class=fn>bool <a name="opaqueMoving-prop"></a>opaqueMoving</h3>
<p>This property holds whether dock windows are moved opaquely.
<p>If TRUE the dock windows of the main window are shown opaquely
(i.e. it shows the toolbar as it looks when docked) whilst it is
being moved. If FALSE (the default) they are shown transparently,
(i.e. as an outline rectangle).
<p> <b>Warning:</b> Opaque moving of toolbars and dockwindows is known to
have several problems. We recommend avoiding the use of this
feature for the time being. We intend fixing the problems in a
future release.
<p>Set this property's value with <a href="#setOpaqueMoving">setOpaqueMoving</a>() and get this property's value with <a href="#opaqueMoving">opaqueMoving</a>().
<h3 class=fn>bool <a name="rightJustification-prop"></a>rightJustification</h3>
<b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> <p>This property holds whether the main window right-justifies its dock windows.
<p>If disabled (the default), stretchable dock windows are expanded,
and non-stretchable dock windows are given the minimum space they
need. Since most dock windows are not stretchable, this usually
results in an unjustified right edge (or unjustified bottom edge
for a vertical dock area). If enabled, the main window will
right-justify its dock windows.
<p> <p>See also <a href="qdockwindow.html#setVerticalStretchable">QDockWindow::setVerticalStretchable</a>() and <a href="qdockwindow.html#setHorizontalStretchable">QDockWindow::setHorizontalStretchable</a>().
<p>Set this property's value with <a href="#setRightJustification">setRightJustification</a>() and get this property's value with <a href="#rightJustification">rightJustification</a>().
<h3 class=fn>bool <a name="usesBigPixmaps-prop"></a>usesBigPixmaps</h3>
<p>This property holds whether big pixmaps are enabled.
<p>If FALSE (the default), the tool buttons will use small pixmaps;
otherwise big pixmaps will be used.
<p> Tool buttons and other widgets that wish to respond to this
setting are responsible for reading the correct state on startup,
and for connecting to the main window's widget's
<a href="#pixmapSizeChanged">pixmapSizeChanged</a>() signal.
<p>Set this property's value with <a href="#setUsesBigPixmaps">setUsesBigPixmaps</a>() and get this property's value with <a href="#usesBigPixmaps">usesBigPixmaps</a>().
<h3 class=fn>bool <a name="usesTextLabel-prop"></a>usesTextLabel</h3>
<p>This property holds whether text labels for toolbar buttons are enabled.
<p>If disabled (the default), the tool buttons will not use text
labels. If enabled, text labels will be used.
<p> Tool buttons and other widgets that wish to respond to this
setting are responsible for reading the correct state on startup,
and for connecting to the main window's widget's
<a href="#usesTextLabelChanged">usesTextLabelChanged</a>() signal.
<p> <p>See also <a href="qtoolbutton.html#usesTextLabel-prop">QToolButton::usesTextLabel</a>.
<p>Set this property's value with <a href="#setUsesTextLabel">setUsesTextLabel</a>() and get this property's value with <a href="#usesTextLabel">usesTextLabel</a>().
<hr><h2>Related Functions</h2>
<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 )
</h3>
<p> Writes the layout (sizes and positions) of the dock windows in the
dock 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>.
<p> This can be used, for example, in conjunction with <a href="qsettings.html">QSettings</a> to
save the user's layout when the \mainWindow receives a closeEvent.
<p> <p>See also <a href="#operator-gt-gt">operator&gt;&gt;</a>() and <a href="qwidget.html#closeEvent">closeEvent</a>().
<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 )
</h3>
<p> Reads the layout (sizes and positions) of the dock windows in the
dock areas of the QMainWindow <em>mainWindow</em> from the text stream,
<em>ts</em>, including <a href="qt.html#Dock-enum">Minimized</a> and <a href="qt.html#Dock-enum">TornOff</a> dock windows.
Restores the dock windows and dock areas to these sizes and
positions. The layout information must be in the format produced
by <a href="#operator-lt-lt">operator&lt;&lt;</a>().
<p> This can be used, for example, in conjunction with <a href="qsettings.html">QSettings</a> to
restore the user's layout.
<p> <p>See also <a href="#operator-lt-lt">operator&lt;&lt;</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>