Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QMainWindow Class Reference

The QMainWindow class provides a main application window. More...

    #include <QMainWindow>

Inherits QWidget.

- List of all members, including inherited members
- Obsolete members

### Writable Properties

- iconSize : Qt::IconSize
- toolButtonStyle : Qt::ToolButtonStyle

- 33 writable properties inherited from QWidget
- 1 writable property inherited from QObject

### Read-Only Properties

- 20 read-only properties inherited from QWidget

### Public Functions

- QMainWindow ( QWidget * parent = 0, Qt::WFlags flags = 0 )
- ~QMainWindow ()
- void addDockWindow ( Qt::DockWindowArea area, QDockWindow * dockwindow )
- void addToolBar ( Qt::ToolBarArea area, QToolBar * toolbar )
- void addToolBar ( QToolBar * toolbar )
- void addToolBarBreak ( Qt::ToolBarArea area )
- QWidget * centralWidget () const
- Qt::DockWindowArea corner ( Qt::Corner corner ) const
- virtual QMenu * createPopupMenu ()
- Qt::DockWindowArea dockWindowArea ( QDockWindow * dockwindow ) const
- void extendDockWindowArea ( Qt::DockWindowArea area, QDockWindow * dockwindow, Qt::Orientation orientation )
- void insertToolBar ( QToolBar * before, QToolBar * toolbar )
- void insertToolBarBreak ( QToolBar * before )
- QMenuBar * menuBar () const
- void removeDockWindow ( QDockWindow * dockwindow )
- void removeToolBar ( QToolBar * toolbar )
- bool restoreState ( const QByteArray & state, int version = 0 )
- QByteArray saveState ( int version = 0 ) const
- void setCentralWidget ( QWidget * widget )
- void setCorner ( Qt::Corner corner, Qt::DockWindowArea area )
- void setMenuBar ( QMenuBar * menubar )
- void setStatusBar ( QStatusBar * statusbar )
- void splitDockWindow ( QDockWindow * after, QDockWindow * dockwindow, Qt::Orientation orientation )
- QStatusBar * statusBar () const
- Qt::ToolBarArea toolBarArea ( QToolBar * toolbar ) const

- 92 public functions inherited from QWidget
- 26 public functions inherited from QObject
- 10 public functions inherited from QPaintDevice

### Public Slots

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

### Signals

- void iconSizeChanged ( Qt::IconSize iconSize )
- void toolButtonStyleChanged ( Qt::ToolButtonStyle toolButtonStyle )

- 1 signal inherited from QObject

### Static Public Members

- 4 static public members inherited from QWidget
- 4 static public members inherited from QObject

### Protected Functions

- 42 protected functions inherited from QWidget
- 7 protected functions inherited from QObject

## Detailed Description

The QMainWindow class provides a main application window.

QMainWindow provides a main application window, with a menu bar, tool bars, dock windows and a status bar around a large central widget, such as a text edit, drawing canvas or QWorkspace (for MDI applications).

See also QDockWindow and QToolBar.

## Property Documentation

### iconSize : Qt::IconSize

This property holds size of toolbar icons in this mainwindow.

The default is Qt::AutomaticIconSize.

Access functions:

- Qt::IconSize iconSize () const
- void setIconSize ( Qt::IconSize iconSize )

### toolButtonStyle : Qt::ToolButtonStyle

This property holds style of toolbar buttons in this mainwindow.

The default is Qt::ToolButtonIconOnly.

Access functions:

- Qt::ToolButtonStyle toolButtonStyle () const
- void setToolButtonStyle ( Qt::ToolButtonStyle toolButtonStyle )

## Member Function Documentation

### QMainWindow::QMainWindow ( QWidget * parent = 0, Qt::WFlags flags = 0 )

Constructs a QMainWindow with the given parent and the specified widget flags.

### QMainWindow::~QMainWindow ()

Destroys the main window.

### void QMainWindow::addDockWindow ( Qt::DockWindowArea area, QDockWindow * dockwindow )

### void QMainWindow::addToolBar ( Qt::ToolBarArea area, QToolBar * toolbar )

Adds the toolbar into the specified area in this main window. The toolbar is placed at the end of the current tool bar block (i.e. line).

See also insertToolBar(), addToolBarBlock(), and insertToolBarBlock().

### void QMainWindow::addToolBar ( QToolBar * toolbar )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Equivalent of calling addToolBar(Qt::ToolBarAreaTop, toolbar)

### void QMainWindow::addToolBarBreak ( Qt::ToolBarArea area )

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

Returns the central widget for the main window. This function returns zero if the central widget has not been set.

See also setCentralWidget().

### Qt::DockWindowArea QMainWindow::corner ( Qt::Corner corner ) const

Returns the dock window area that occupies the specified corner.

See also setCorner().

### QMenu * QMainWindow::createPopupMenu () `[virtual]`

This function is called to create a popup menu when the user right-clicks a toolbar or dock window. If you want to create a custom popup menu, reimplement this function and return the created popup menu. Ownership of the popup menu is transferred to the caller.

### Qt::DockWindowArea QMainWindow::dockWindowArea ( QDockWindow * dockwindow ) const

Returns the `Qt::DockWindowArea` for dockwindow.

See also addDockWindow(), extendDockWindowArea(), splitDockWindow(), and Qt::DockWindowArea.

### void QMainWindow::extendDockWindowArea ( Qt::DockWindowArea area, QDockWindow * dockwindow, Qt::Orientation orientation )

### void QMainWindow::iconSizeChanged ( Qt::IconSize iconSize ) `[signal]`

### void QMainWindow::insertToolBar ( QToolBar * before, QToolBar * toolbar )

Inserts the toolbar into the specified area in this main window. The toolbar is placed before the toolbar before.

See also insertToolBarBlock(), addToolBar(), and addToolBarBlock().

### void QMainWindow::insertToolBarBreak ( QToolBar * before )

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

Returns the menu bar for the main window. This function creates and returns an empty menu bar if the menu bar does not exist.

See also setMenuBar().

### void QMainWindow::removeDockWindow ( QDockWindow * dockwindow )

Removes the dockwindow from the main window.

### void QMainWindow::removeToolBar ( QToolBar * toolbar )

Removes the toolbar from the main window.

### bool QMainWindow::restoreState ( const QByteArray & state, int version = 0 )

Restores the state of this mainwindow's toolbars and dockwindows. The version number is compared with that stored in state. If they do not match, the mainwindow's state is left unchanged, and this function returns false; otherwise, the state is restored, and this function returns true.

See also saveState().

### QByteArray QMainWindow::saveState ( int version = 0 ) const

Saves the current state of this mainwindow's toolbars and dockwindows. The version number is stored as part of the data.

To restore the saved state, pass the return value and version number to restoreState().

See also restoreState().

### void QMainWindow::setCentralWidget ( QWidget * widget )

Sets the given widget to be the main window's central widget.

Warning: This function should be called at most once for each main window instance

See also centralWidget().

### void QMainWindow::setCorner ( Qt::Corner corner, Qt::DockWindowArea area )

Sets the given dock window area to occupy the specified corner.

See also corner().

### void QMainWindow::setMenuBar ( QMenuBar * menubar )

Sets the menu bar for the main window to menubar.

See also menuBar().

### void QMainWindow::setStatusBar ( QStatusBar * statusbar )

Sets the status bar for the main window to statusbar.

See also statusBar().

### void QMainWindow::splitDockWindow ( QDockWindow * after, QDockWindow * dockwindow, Qt::Orientation orientation )

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

Returns the status bar for the main window. This function creates and returns an empty status bar if the status bar does not exist.

See also setStatusBar().

### Qt::ToolBarArea QMainWindow::toolBarArea ( QToolBar * toolbar ) const

Returns the tool bar area for toolbar.

See also addToolBar(), addToolBarBlock(), and Qt::ToolBarArea.

### void QMainWindow::toolButtonStyleChanged ( Qt::ToolButtonStyle toolButtonStyle ) `[signal]`