Qt Reference Documentation

# Q3MainWindow Class Reference

The Q3MainWindow class provides a main application window, with a menu bar, dock windows (e.g. for toolbars), and a status bar. More...

     #include <Q3MainWindow>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits: QWidget.

- List of all members, including inherited members

## Public Types

enum | DockWindows { OnlyToolBars, NoToolBars, AllDockWindows }

## Properties

- dockWindowsMovable : bool
- opaqueMoving : bool
- rightJustification : bool

- usesBigPixmaps : bool
- usesTextLabel : bool

- 58 properties inherited from QWidget
- 1 property inherited from QObject

## Public Functions

| Q3MainWindow ( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = Qt::WType_TopLevel )
| ~Q3MainWindow ()
virtual void | addDockWindow ( Q3DockWindow * dockWindow, Qt::Dock edge = Qt::DockTop, bool newLine = false )
virtual void | addDockWindow ( Q3DockWindow * dockWindow, const QString & label, Qt::Dock edge = Qt::DockTop, bool newLine = false )
void | addToolBar ( Q3DockWindow * dockWindow, Qt::Dock position = Qt::DockTop, bool newLine = false )
void | addToolBar ( Q3DockWindow * dockWindow, const QString & label, Qt::Dock position = Qt::DockTop, bool newLine = false )
bool | appropriate ( Q3DockWindow * dw ) const
Q3DockArea * | bottomDock () const
QWidget * | centralWidget () const
virtual Q3PopupMenu * | createDockWindowMenu ( DockWindows dockWindows = AllDockWindows ) const
QList<Q3DockWindow *> | dockWindows ( Qt::Dock dock ) const
QList<Q3DockWindow *> | dockWindows () const
bool | dockWindowsMovable () const
bool | getLocation ( Q3DockWindow * dw, Qt::Dock & dock, int & index, bool & nl, int & extraOffset ) const
bool | hasDockWindow ( Q3DockWindow * dw )
virtual bool | isCustomizable () const
bool | isDockEnabled ( Qt::Dock dock ) const
bool | isDockEnabled ( Q3DockArea * area ) const
bool | isDockEnabled ( Q3DockWindow * dw, Q3DockArea * area ) const
bool | isDockEnabled ( Q3DockWindow * tb, Qt::Dock dock ) const
bool | isDockMenuEnabled () const
Q3DockArea * | leftDock () const
void | lineUpDockWindows ( bool keepNewLines = false )
void | lineUpToolBars ( bool keepNewLines = false )
QMenuBar * | menuBar () const
virtual void | moveDockWindow ( Q3DockWindow * dockWindow, Qt::Dock edge = Qt::DockTop )
virtual void | moveDockWindow ( Q3DockWindow * dockWindow, Qt::Dock edge, bool nl, int index, int extraOffset = -1 )
void | moveToolBar ( Q3DockWindow * dockWindow, Qt::Dock position = Qt::DockTop )
void | moveToolBar ( Q3DockWindow * dockWindow, Qt::Dock position, bool nl, int index, int extraOffset = -1 )
bool | opaqueMoving () const
virtual void | removeDockWindow ( Q3DockWindow * dockWindow )
void | removeToolBar ( Q3DockWindow * dockWindow )
Q3DockArea * | rightDock () const
bool | rightJustification () const
virtual void | setCentralWidget ( QWidget * w )
virtual void | setDockEnabled ( Qt::Dock dock, bool enable )
virtual void | setDockEnabled ( Q3DockWindow * dw, Qt::Dock dock, bool enable )
QStatusBar * | statusBar () const
QList<Q3ToolBar *> | toolBars ( Qt::Dock dock ) const
bool | toolBarsMovable () const
Q3DockArea * | topDock () const
bool | usesBigPixmaps () const
bool | usesTextLabel () const

## Reimplemented Public Functions

virtual bool | eventFilter ( QObject * o, QEvent * e )
virtual QSize | minimumSizeHint () const
virtual void | setVisible ( bool visible )
virtual QSize | sizeHint () const

- 221 public functions inherited from QWidget
- 29 public functions inherited from QObject
- 13 public functions inherited from QPaintDevice

## Public Slots

virtual void | customize ()
virtual void | setAppropriate ( Q3DockWindow * dw, bool a )
virtual void | setDockMenuEnabled ( bool b )
virtual void | setDockWindowsMovable ( bool )
virtual void | setOpaqueMoving ( bool )
virtual void | setRightJustification ( bool )
void | setToolBarsMovable ( bool b )
virtual void | setUsesBigPixmaps ( bool )
virtual void | setUsesTextLabel ( bool )
virtual void | whatsThis ()

- 19 public slots inherited from QWidget
- 1 public slot inherited from QObject

## Signals

void | dockWindowPositionChanged ( Q3DockWindow * dockWindow )
void | pixmapSizeChanged ( bool b )
void | toolBarPositionChanged ( Q3ToolBar * toolbar )
void | usesTextLabelChanged ( bool b )

- 1 signal inherited from QWidget
- 1 signal inherited from QObject

## Reimplemented Protected Functions

virtual void | childEvent ( QChildEvent * e )
virtual bool | event ( QEvent * e )
virtual void | paintEvent ( QPaintEvent * )

- 37 protected functions inherited from QWidget
- 8 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice

## Protected Slots

void | menuAboutToShow ()
virtual void | setUpLayout ()
virtual bool | showDockMenu ( const QPoint & globalPos )

- 1 protected slot inherited from QWidget

## Related Non-Members

QTextStream & | operator<< ( QTextStream & ts, const Q3MainWindow & mainWindow )
QTextStream & | operator>> ( QTextStream & ts, Q3MainWindow & mainWindow )

### Additional Inherited Members

- 4 static public members inherited from QWidget
- 7 static public members inherited from QObject
- 37 protected functions inherited from QWidget
- 8 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice

## Detailed Description

The Q3MainWindow class provides a main application window, with a menu bar, dock windows (e.g. for toolbars), and a status bar.

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 QWorkspace (for MDI applications). Q3MainWindow 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.

We'll briefly review adding menu items and toolbar buttons then describe the facilities of Q3MainWindow itself.

     Q3MainWindow *mw = new Q3MainWindow;
     QTextEdit *edit = new QTextEdit(mw, "editor");
     edit->setFocus();
     mw->setWindowTitle("Main Window");
     mw->setCentralWidget(edit);
     mw->show();

Q3MainWindows may be created in their own right as shown above. The central widget is set with setCentralWidget(). 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.

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. Q3MainWindow automatically detects the creation of a menu bar or status bar if you specify the Q3MainWindow as parent, or you can use the provided menuBar() and statusBar() functions. The functions menuBar() and statusBar() create a suitable widget if one doesn't exist, and update the window's layout to make space.

New dock windows and toolbars can be added to a Q3MainWindow using addDockWindow(). Qt::Dock windows can be moved using moveDockWindow() and removed with removeDockWindow(). Q3MainWindow allows default dock window (toolbar) docking in all its dock areas (`Top`, `Left`, `Right`, `Bottom`). You can use setDockEnabled() 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: `Top`, `Left`, `Right`, `Bottom`, `Minimized` (effectively a 'hidden' dock area) and `TornOff` (floating). See Qt::Dock 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 Q3DockWindow so all functions that work with dock windows work on toolbars in the same way.

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 createDockWindowMenu(). Since it may not always be appropriate for a dock window to appear on this menu the setAppropriate() 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 title bar will dock the floating dock window. (See also Q3MainWindow::DockWindows.)

Some functions change the appearance of a Q3MainWindow globally:

- Q3DockWindow::setHorizontalStretchable() and Q3DockWindow::setVerticalStretchable() are used to make specific dock windows or toolbars stretchable.
- setUsesBigPixmaps() is used to set whether tool buttons should draw small or large pixmaps (see QIcon for more information).
- setUsesTextLabel() is used to set whether tool buttons should display a textual label in addition to pixmaps (see QToolButton for more information).

The user can drag dock windows into any enabled docking area. Qt::Dock windows can also be dragged within a docking area, for example to rearrange the order of some toolbars. Qt::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 setDockWindowsMovable().

The `Minimized` 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 Q3DockWindow::windowTitle() or Q3ToolBar::label()), so if you enable the `Minimized` dock area, it is best to specify a meaningful caption or label for each dock window. To minimize a dock window programmatically use moveDockWindow() with an edge of `Minimized`.

Qt::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 setOpaqueMoving().

The location of a dock window, i.e. its dock area and position within the dock area, can be determined by calling getLocation(). Movable dock windows can be lined up to minimize wasted space with lineUpDockWindows(). Pointers to the dock areas are available from topDock(), leftDock(), rightDock() and bottomDock(). A customize menu item is added to the pop up dock window menu if isCustomizable() returns true; it returns false by default. Reimplement isCustomizable() and customize() 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.

The main window's menu bar is fixed (at the top) by default. If you want a movable menu bar, create a QMenuBar as a stretchable widget inside its own movable dock window and restrict this dock window to only live within the `Top` or `Bottom` dock:

     Q3ToolBar *tb = new Q3ToolBar(this);
     addDockWindow(tb, tr("Menubar"), Top, false);
     QMenuBar *mb = new QMenuBar(tb);
     mb->setFrameStyle(QFrame::NoFrame);
     tb->setStretchableWidget(mb);
     setDockEnabled(tb, Left, false);
     setDockEnabled(tb, Right, false);

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 Q3MainWindow.

To save the layout and positions of all the dock windows do this:

     QFile file(filename);
     if (file.open(IO_WriteOnly)) {
         QTextStream stream(&file);
         stream << *mainWindow;
         file.close();
     }

To restore the dock window positions and sizes (normally when the application is next started), do the following:

     QFile file(filename);
     if (file.open(IO_ReadOnly)) {
         QTextStream stream(&file);
         stream >> *mainWindow;
         file.close();
     }

The QSettings class can be used in conjunction with the streaming operators to store the application's settings.

Q3MainWindow's management of dock windows and toolbars is done transparently behind-the-scenes by Q3DockArea.

For multi-document interfaces (MDI), use a QWorkspace as the central widget.

Adding dock windows, e.g. toolbars, to Q3MainWindow's dock areas is straightforward. If the supplied dock areas are not sufficient for your application we suggest that you create a QWidget subclass and add your own dock areas (see Q3DockArea) to the subclass since Q3MainWindow provides functionality specific to the standard dock areas it provides.

See also Q3ToolBar, Q3DockWindow, QStatusBar, QAction, QMenuBar, Q3PopupMenu, and QDialog.

## Member Type Documentation

### enum Q3MainWindow::DockWindows

Right-clicking a dock area will pop-up the dock window menu (createDockWindowMenu() is called automatically). When called in code you can specify what items should appear on the menu with this enum.

Constant | Value | Description
--- | --- | ---
`Q3MainWindow::OnlyToolBars` | `0` | The menu will list all the toolbars, but not any other dock windows.
`Q3MainWindow::NoToolBars` | `1` | The menu will list dock windows but not toolbars.
`Q3MainWindow::AllDockWindows` | `2` | The menu will list all toolbars and other dock windows. (This is the default.)

## Property Documentation

### dockWindowsMovable : bool

This property holds whether the dock windows are movable.

If true (the default), the user will be able to move movable dock windows from one Q3MainWindow dock area to another, including the `TearOff` area (i.e. where the dock window floats freely as a window in its own right), and the `Minimized` area (where only the dock window's handle is shown below the menu bar). Movable dock windows can also be moved within Q3MainWindow dock areas, i.e. to rearrange them within a dock area.

If false the user will not be able to move any dock windows.

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 setOpaqueMoving().

Access functions:

bool | dockWindowsMovable () const
virtual void | setDockWindowsMovable ( bool )

See also setDockEnabled() and setOpaqueMoving().

### opaqueMoving : bool

This property holds whether dock windows are moved opaquely.

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).

Warning: 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.

Access functions:

bool | opaqueMoving () const
virtual void | setOpaqueMoving ( bool )

### rightJustification : bool

This property holds whether the main window right-justifies its dock windows.

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.

Access functions:

bool | rightJustification () const
virtual void | setRightJustification ( bool )

See also Q3DockWindow::setVerticalStretchable() and Q3DockWindow::setHorizontalStretchable().

### usesBigPixmaps : bool

This property holds whether big pixmaps are enabled.

If false (the default), the tool buttons will use small pixmaps; otherwise big pixmaps will be used.

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 pixmapSizeChanged() signal.

Access functions:

bool | usesBigPixmaps () const
virtual void | setUsesBigPixmaps ( bool )

### usesTextLabel : bool

This property holds whether text labels for toolbar buttons are enabled.

If disabled (the default), the tool buttons will not use text labels. If enabled, text labels will be used.

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 usesTextLabelChanged() signal.

Access functions:

bool | usesTextLabel () const
virtual void | setUsesTextLabel ( bool )

See also QToolButton::setUsesTextLabel().

## Member Function Documentation

### Q3MainWindow::Q3MainWindow ( QWidget * parent = 0, const char * name = 0, Qt::WindowFlags f = Qt::WType_TopLevel )

Constructs an empty main window. The parent, name and widget flags f, are passed on to the QWidget constructor.

By default, the widget flags are set to Qt::WType_TopLevel rather than 0 as they are with QWidget. If you don't want your Q3MainWindow to be a top level widget then you will need to set f to 0.

### Q3MainWindow::~Q3MainWindow ()

Destroys the object and frees any allocated resources.

### void Q3MainWindow::addDockWindow ( Q3DockWindow * dockWindow, Qt::Dock edge = Qt::DockTop, bool newLine = false )`[virtual]`

Adds dockWindow to the edge dock area.

If newLine is false (the default) then the dockWindow is added at the end of the edge. For vertical edges the end is at the bottom, for horizontal edges (including `Minimized`) the end is at the right. If newLine is true a new line of dock windows is started with dockWindow as the first (left-most and top-most) dock window.

If dockWindow is managed by another main window, it is first removed from that window.

### void Q3MainWindow::addDockWindow ( Q3DockWindow * dockWindow, const QString & label, Qt::Dock edge = Qt::DockTop, bool newLine = false )`[virtual]`

This is an overloaded function.

Adds dockWindow to the dock area with label label.

If newLine is false (the default) the dockWindow is added at the end of the edge. For vertical edges the end is at the bottom, for horizontal edges (including `Minimized`) the end is at the right. If newLine is true a new line of dock windows is started with dockWindow as the first (left-most and top-most) dock window.

If dockWindow is managed by another main window, it is first removed from that window.

### void Q3MainWindow::addToolBar ( Q3DockWindow * dockWindow, Qt::Dock position = Qt::DockTop, bool newLine = false )

Adds a new toolbar to the dockWindow. The toolbar is placed in the given position. If newLine is true the toolbar is put on a new line.

### void Q3MainWindow::addToolBar ( Q3DockWindow * dockWindow, const QString & label, Qt::Dock position = Qt::DockTop, bool newLine = false )

This is an overloaded function.

The toolbar has the caption label and is placed in the given position.

### bool Q3MainWindow::appropriate ( Q3DockWindow * dw ) const

Returns true if it is appropriate to include a menu item for the dw dock window in the dock window menu; otherwise returns false.

The user is able to change the state (show or hide) a dock window that has a menu item by clicking the item.

Call setAppropriate() to indicate whether or not a particular dock window should appear on the popup menu.

See also setAppropriate().

### Q3DockArea * Q3MainWindow::bottomDock () const

Returns a pointer the `Bottom` dock area

See also topDock(), leftDock(), and rightDock().

### QWidget * Q3MainWindow::centralWidget () const

Returns a pointer to the main window's central widget.

The central widget is surrounded by the left, top, right and bottom dock areas. The menu bar is above the top dock area.

See also setCentralWidget().

### void Q3MainWindow::childEvent ( QChildEvent * e )`[virtual protected]`

Reimplemented from QObject::childEvent().

Monitors events, received in e, to ensure the layout is updated.

### Q3PopupMenu * Q3MainWindow::createDockWindowMenu ( DockWindows dockWindows = AllDockWindows ) const`[virtual]`

Creates the dock window menu which contains all toolbars (if dockWindows is `OnlyToolBars`), all dock windows (if dockWindows is `NoToolBars`) or all toolbars and dock windows (if dockWindows is `AllDockWindows` - the default).

This function is called internally when necessary, e.g. when the user right clicks a dock area (providing isDockMenuEnabled() returns true). You can reimplement this function if you wish to customize the behavior.

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).

The list and the state are always kept up-to-date.

Toolbars and dock windows which are not appropriate in the current context (see setAppropriate()) are not listed in the menu.

The menu also has a menu item for lining up the dock windows.

If isCustomizable() returns true, a Customize menu item is added to the menu, which if clicked will call customize(). The isCustomizable() function we provide returns false and customize() does nothing, so they must be reimplemented in a subclass to be useful.

### void Q3MainWindow::customize ()`[virtual slot]`

This function is called when the user clicks the Customize menu item on the dock window menu.

The customize menu item will only appear if isCustomizable() returns true (it returns false by default).

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.

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.

See also isCustomizable().

### void Q3MainWindow::dockWindowPositionChanged ( Q3DockWindow * dockWindow )`[signal]`

This signal is emitted when the dockWindow 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 `Minimized` and `TearOff` dock areas).

See also getLocation().

### QList<Q3DockWindow *> Q3MainWindow::dockWindows ( Qt::Dock dock ) const

Returns a list of all the dock windows which are in the dock dock area, regardless of their state.

For example, the Qt::DockTornOff dock area may contain closed dock windows but these are returned along with the visible dock windows.

### QList<Q3DockWindow *> Q3MainWindow::dockWindows () const

This is an overloaded function.

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).

### bool Q3MainWindow::event ( QEvent * e )`[virtual protected]`

Reimplemented from QObject::event().

### bool Q3MainWindow::eventFilter ( QObject * o, QEvent * e )`[virtual]`

Reimplemented from QObject::eventFilter().

### bool Q3MainWindow::getLocation ( Q3DockWindow * dw, Qt::Dock & dock, int & index, bool & nl, int & extraOffset ) const

Finds the location of the dock window dw.

If the dw dock window is found in the main window the function returns true and populates the dock variable with the dw's dock area and the index with the dw's position within the dock area. It also sets nl to true if the dw begins a new line (otherwise false), and extraOffset with the dock window's offset.

If the dw dock window is not found then the function returns false and the state of dock, index, nl and extraOffset is undefined.

If you want to save and restore dock window positions then use operator>>() and operator<<().

### bool Q3MainWindow::hasDockWindow ( Q3DockWindow * dw )

Returns true if dw is a dock window known to the main window; otherwise returns false.

### bool Q3MainWindow::isCustomizable () const`[virtual]`

Returns true if the dock area dock window menu includes the Customize menu item (which calls customize() 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.

See also customize().

### bool Q3MainWindow::isDockEnabled ( Qt::Dock dock ) const

Returns true if the dock dock area is enabled, i.e. it can accept user dragged dock windows; otherwise returns false.

See also setDockEnabled().

### bool Q3MainWindow::isDockEnabled ( Q3DockArea * area ) const

This is an overloaded function.

Returns true if dock area area is enabled, i.e. it can accept user dragged dock windows; otherwise returns false.

See also setDockEnabled().

### bool Q3MainWindow::isDockEnabled ( Q3DockWindow * dw, Q3DockArea * area ) const

This is an overloaded function.

Returns true if dock area area is enabled for the dock window dw; otherwise returns false.

See also setDockEnabled().

### bool Q3MainWindow::isDockEnabled ( Q3DockWindow * tb, Qt::Dock dock ) const

This is an overloaded function.

Returns true if dock area dock is enabled for the dock window tb; otherwise returns false.

See also setDockEnabled().

### bool Q3MainWindow::isDockMenuEnabled () const

Returns true, if the dock window menu is enabled; otherwise returns false.

The menu lists the (appropriate()) 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 isCustomizable() returns true.

setAppropriate()

See also setDockEnabled(), lineUpDockWindows(), and appropriate().

### Q3DockArea * Q3MainWindow::leftDock () const

Returns the `Left` dock area

See also rightDock(), topDock(), and bottomDock().

### void Q3MainWindow::lineUpDockWindows ( bool keepNewLines = false )

This function will line up dock windows within the visible dock areas (`Top`, `Left`, `Right` and `Bottom`) as compactly as possible.

If keepNewLines is true, all dock windows stay on their original lines. If keepNewLines is false then newlines may be removed to achieve the most compact layout possible.

The method only works if dockWindowsMovable() returns true.

### void Q3MainWindow::lineUpToolBars ( bool keepNewLines = false )

Lines up the toolbars. Line breaks are preserved if keepNewLines is true.

### void Q3MainWindow::menuAboutToShow ()`[protected slot]`

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.

### QMenuBar * Q3MainWindow::menuBar () const

Returns the menu bar for this window.

If there isn't one, then menuBar() creates an empty menu bar.

See also statusBar().

### QSize Q3MainWindow::minimumSizeHint () const`[virtual]`

Reimplemented from QWidget::minimumSizeHint().

### void Q3MainWindow::moveDockWindow ( Q3DockWindow * dockWindow, Qt::Dock edge = Qt::DockTop )`[virtual]`

Moves dockWindow to the end of the edge.

For vertical edges the end is at the bottom, for horizontal edges (including `Minimized`) the end is at the right.

If dockWindow is managed by another main window, it is first removed from that window.

### void Q3MainWindow::moveDockWindow ( Q3DockWindow * dockWindow, Qt::Dock edge, bool nl, int index, int extraOffset = -1 )`[virtual]`

This is an overloaded function.

Moves dockWindow to position index within the edge dock area.

Any dock windows with positions index 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.

If nl 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.

The extraOffset 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.)

If dockWindow is managed by another main window, it is first removed from that window.

### void Q3MainWindow::moveToolBar ( Q3DockWindow * dockWindow, Qt::Dock position = Qt::DockTop )

Moves the given dockWindow into the given position.

### void Q3MainWindow::moveToolBar ( Q3DockWindow * dockWindow, Qt::Dock position, bool nl, int index, int extraOffset = -1 )

This is an overloaded function.

The dockWindow is made the index-th item in the toolbar, moved over by extraOffset. If nl is true, the dock window is put on a new line.

### void Q3MainWindow::paintEvent ( QPaintEvent * )`[virtual protected]`

Reimplemented from QWidget::paintEvent().

### void Q3MainWindow::pixmapSizeChanged ( bool b )`[signal]`

This signal is emitted whenever the setUsesBigPixmaps() is called with a value different to the current setting. The new value is passed in b. All widgets that should respond to such changes, e.g. toolbar buttons, must connect to this signal.

### void Q3MainWindow::removeDockWindow ( Q3DockWindow * dockWindow )`[virtual]`

Removes dockWindow from the main window's docking area, provided dockWindow is non-null and managed by this main window.

### void Q3MainWindow::removeToolBar ( Q3DockWindow * dockWindow )

Removes the toolbar from the given dockWindow.

### Q3DockArea * Q3MainWindow::rightDock () const

Returns the `Right` dock area

See also leftDock(), topDock(), and bottomDock().

### void Q3MainWindow::setAppropriate ( Q3DockWindow * dw, bool a )`[virtual slot]`

Use this function to control whether or not the dw dock window's caption should appear as a menu item on the dock window menu that lists the dock windows.

If a is true then the dw 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 a is false the dw will not appear on the popup menu.

See also appropriate(), showDockMenu(), isCustomizable(), and customize().

### void Q3MainWindow::setCentralWidget ( QWidget * w )`[virtual]`

Sets the central widget for this main window to w.

The central widget is surrounded by the left, top, right and bottom dock areas. The menu bar is above the top dock area.

See also centralWidget().

### void Q3MainWindow::setDockEnabled ( Qt::Dock dock, bool enable )`[virtual]`

If enable is true then users can dock windows in the dock area. If enable is false users cannot dock windows in the dock dock area.

Users can dock (drag) dock windows into any enabled dock area.

See also isDockEnabled().

### void Q3MainWindow::setDockEnabled ( Q3DockWindow * dw, Qt::Dock dock, bool enable )`[virtual]`

This is an overloaded function.

If enable is true then users can dock the dw dock window in the dock area. If enable is false users cannot dock the dw dock window in the dock area.

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.

### void Q3MainWindow::setDockMenuEnabled ( bool b )`[virtual slot]`

If b is true, then right clicking on a dock window or dock area will pop up the dock window menu. If b is false, right clicking a dock window or dock area will not pop up the menu.

The menu lists the (appropriate()) 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 isCustomizable() returns true.

See also lineUpDockWindows() and isDockMenuEnabled().

### void Q3MainWindow::setToolBarsMovable ( bool b )`[slot]`

If b is true the tool bars can be moved.

See also toolBarsMovable().

### void Q3MainWindow::setUpLayout ()`[virtual protected slot]`

Sets up the geometry management of the window. It is called automatically when needed, so you shouldn't need to call it.

### void Q3MainWindow::setVisible ( bool visible )`[virtual]`

Reimplemented from QWidget::setVisible().

### bool Q3MainWindow::showDockMenu ( const QPoint & globalPos )`[virtual protected slot]`

Shows the dock menu at the position globalPos. 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.

If you want a custom menu, reimplement this function. You can create the menu from scratch or call createDockWindowMenu() and modify the result.

The default implementation uses the dock window menu which gets created by createDockWindowMenu(). You can reimplement createDockWindowMenu() if you want to use your own specialized popup menu.

### QSize Q3MainWindow::sizeHint () const`[virtual]`

Reimplemented from QWidget::sizeHint().

### QStatusBar * Q3MainWindow::statusBar () const

Returns this main window's status bar. If there isn't one, statusBar() creates an empty status bar, and if necessary a tool tip group too.

See also menuBar().

### void Q3MainWindow::toolBarPositionChanged ( Q3ToolBar * toolbar )`[signal]`

This signal is emitted when a toolbar is moved.

### QList<Q3ToolBar *> Q3MainWindow::toolBars ( Qt::Dock dock ) const

Returns a list of all the toolbars which are in the dock dock area, regardless of their state.

For example, the `TornOff` dock area may contain closed toolbars but these are returned along with the visible toolbars.

See also dockWindows().

### bool Q3MainWindow::toolBarsMovable () const

Returns true if the window allows its toolbars to be moved; otherwise returns false.

See also setToolBarsMovable().

### Q3DockArea * Q3MainWindow::topDock () const

Returns the `Top` dock area

See also bottomDock(), leftDock(), and rightDock().

### void Q3MainWindow::usesTextLabelChanged ( bool b )`[signal]`

This signal is emitted whenever the setUsesTextLabel() is called with a value different to the current setting. The new value is passed in b. All widgets that should respond to such changes, e.g. toolbar buttons, must connect to this signal.

### void Q3MainWindow::whatsThis ()`[virtual slot]`

Enters 'What's This?' mode and returns immediately.

This is the same as QWhatsThis::enterWhatsThisMode(), but implemented as a main window object's slot. This way it can easily be used for popup menus, for example:

     Q3PopupMenu * help = new Q3PopupMenu(this);
     help->insertItem("What's &This", this , SLOT(enterWhatsThis()), Qt::SHIFT+Qt::Key_F1);

See also Q3WhatsThis::enterWhatsThisMode().

## Related Non-Members

### QTextStream & operator<< ( QTextStream & ts, const Q3MainWindow & mainWindow )

Writes the layout (sizes and positions) of the dock windows in the dock areas of the Q3MainWindow mainWindow, including `Minimized` and `TornOff` dock windows, to the text stream ts.

This can be used, for example, in conjunction with QSettings to save the user's layout when the mainWindow receives a close event.

See also QWidget::closeEvent().

### QTextStream & operator>> ( QTextStream & ts, Q3MainWindow & mainWindow )

Reads the layout (sizes and positions) of the dock windows in the dock areas of the Q3MainWindow mainWindow from the text stream, ts, including `Minimized` and `TornOff` dock windows. Restores the dock windows and dock areas to these sizes and positions. The layout information must be in the format produced by operator<<().

This can be used, for example, in conjunction with QSettings to restore the user's layout.