#include <qmainwindow.h>
Inheritance diagram for QMainWindow:


QMainWindow provides a main application window, with a menu bar, tool bars, dock widgets and a status bar around a large central widget, such as a text edit, drawing canvas or QWorkspace (for MDI applications).
Note that QMainWindow comes with its own customized layout and that setting a layout on a QMainWindow, or creating a layout with a QMainWindow as a parent is considered an error. You should set your own layout on the {centralWidget()}{central widget} instead.
Topics:
The saveState() and restoreState() functions provide a means to save and restore the layout of the QToolBars and QDockWidgets in the QMainWindow. These functions work by storing the \link QObject::objectName objectName\endlink of each QToolBar and QDockWidget together with information about placement, size, etc. @section Behavior of Dock Widgets \target dock-widget-separators @section Dock Widget Separators QMainWindow uses separators to separate QDockWidgets from each other and the \l{centralWidget()}{central widget}. These separators let the user control the size of QDockWidgets by dragging the boundary between them. A QDockWidget can be as large or as small as the user wishes, between the minimumSizeHint() (or minimumSize()) and maximumSize() of the QDockWidget. When a QDockWidget reaches its minimum size, space will be taken from other QDockWidgets in the direction of the user's drag, if possible. Once all QDockWidgets have reached their minimum sizes, further dragging does nothing. When a QDockWidget reaches its maximium size, space will be given to other QDockWidgets in the opposite direction of the user's drag, if possible. Once all QDockWidgets have reached their minimum size, futher dragging does nothing. \target dragging-dock-widgets @section Dragging Dock Widgets QDockWidget displays a title bar to let the user drag the dock widget to a new location. A QDockWidget can be moved to any location provided enough space is available. (QMainWindow won't resize itself to a larger size in an attempt to provide more space.) A QRubberBand is shown while dragging the QDockWidget. This QRubberBand provides an indication to the user about where the QDockWidget will be placed when the mouse button is released. @section Managing Dock Widgets and Toolbars By default, QMainWindow provides a context menu that can be used to toggle the visibility of the toolbars and dock widgets attached to a main window. This menu is usually accessed by right-clicking on a dock window or toolbar, but it can also be obtained programmatically by calling createPopupMenu(). \image mainwindow-contextmenu.png A typical main window context menu. This popup menu can be replaced or customized to suit the specific needs of an application: In a QMainWindow subclass, reimplement createPopupMenu() to either create a custom popup menu by constructing a new QMenu on demand, or to modify the QMenu object obtained by calling the default implementation. \sa QMenuBar, QToolBar, QStatusBar, QDockWidget, {Application Example}, {Dock Widgets Example}, {MDI Example}, {SDI Example} Definition at line 42 of file qmainwindow.h.
| QMainWindow::QMainWindow | ( | QWidget * | parent = 0, |
|
| Qt::WindowFlags | flags = 0 | |||
| ) | [explicit] |
Constructs a QMainWindow with the given parent and the specified widget flags.
Definition at line 218 of file qmainwindow.cpp.
00219 : QWidget(*(new QMainWindowPrivate()), parent, flags | Qt::Window) 00220 { 00221 d_func()->init(); 00222 }
| QMainWindow::~QMainWindow | ( | ) |
| QSize QMainWindow::iconSize | ( | ) | const |
| void QMainWindow::setIconSize | ( | const QSize & | iconSize | ) |
Definition at line 253 of file qmainwindow.cpp.
References d, emit, iconSize(), iconSizeChanged(), QSize::isValid(), QWidget::metric(), QStyle::pixelMetric(), QStyle::PM_ToolBarIconSize, and QWidget::style().
Referenced by event().
00254 { 00255 Q_D(QMainWindow); 00256 QSize sz = iconSize; 00257 if (!sz.isValid()) { 00258 const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize); 00259 sz = QSize(metric, metric); 00260 } 00261 if (d->iconSize != sz) { 00262 d->iconSize = sz; 00263 emit iconSizeChanged(d->iconSize); 00264 } 00265 d->explicitIconSize = iconSize.isValid(); 00266 }
Here is the call graph for this function:

| Qt::ToolButtonStyle QMainWindow::toolButtonStyle | ( | ) | const |
| void QMainWindow::setToolButtonStyle | ( | Qt::ToolButtonStyle | toolButtonStyle | ) |
Definition at line 277 of file qmainwindow.cpp.
References d, emit, and toolButtonStyleChanged().
00278 { 00279 Q_D(QMainWindow); 00280 if (d->toolButtonStyle == toolButtonStyle) 00281 return; 00282 d->toolButtonStyle = toolButtonStyle; 00283 emit toolButtonStyleChanged(d->toolButtonStyle); 00284 }
| bool QMainWindow::isAnimated | ( | ) | const |
| bool QMainWindow::isDockNestingEnabled | ( | ) | const |
| bool QMainWindow::isSeparator | ( | const QPoint & | pos | ) | const |
Definition at line 1005 of file qmainwindow.cpp.
References d, and QWidget::pos().
Referenced by qdesigner_internal::WidgetEditorTool::mainWindowSeparatorEvent().
01006 { 01007 Q_D(const QMainWindow); 01008 #ifndef QT_NO_DOCKWIDGET 01009 return !d->layout->dockWidgetLayout.findSeparator(pos).isEmpty(); 01010 #else 01011 return false; 01012 #endif 01013 }
Here is the call graph for this function:

| 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.
Definition at line 293 of file qmainwindow.cpp.
Referenced by qdesigner_internal::QMainWindowContainer::addWidget(), MainWindow::createMenu(), ImageViewer::createMenus(), MainWindow::createMenus(), QVFb::init(), Main::Main(), main(), MainWindow::MainWindow(), menuWidget(), QVFb::QVFb(), setMenuBar(), setMenuWidget(), TextEdit::setupEditActions(), TextEdit::setupFileActions(), MainWindow::setupFileMenu(), MainWindow::setupHelpMenu(), MainWindow::setupMenuBar(), TrWindow::setupMenuBar(), SpreadSheet::setupMenuBar(), MainWindow::setupMenus(), TextEdit::setupTextActions(), QVFb::sizeHint(), and TextEdit::TextEdit().
00294 { 00295 QMenuBar *menuBar = qobject_cast<QMenuBar *>(d_func()->layout->menuBar()); 00296 if (!menuBar) { 00297 QMainWindow *self = const_cast<QMainWindow *>(this); 00298 menuBar = new QMenuBar(self); 00299 self->setMenuBar(menuBar); 00300 } 00301 return menuBar; 00302 }
| void QMainWindow::setMenuBar | ( | QMenuBar * | menuBar | ) |
Sets the menu bar for the main window to menuBar.
Note: QMainWindow takes ownership of the menuBar pointer and deletes it at the appropriate time.
Definition at line 312 of file qmainwindow.cpp.
Referenced by qdesigner_internal::QMainWindowContainer::addWidget(), qdesigner_internal::QMainWindowContainer::remove(), QDesignerWorkbench::switchToDockedMode(), and QDesignerWorkbench::switchToTopLevelMode().
00313 { 00314 Q_D(QMainWindow); 00315 if (d->layout->menuBar() && d->layout->menuBar() != menuBar) 00316 delete d->layout->menuBar(); 00317 d->layout->setMenuBar(menuBar); 00318 }
Here is the call graph for this function:

| QWidget * QMainWindow::menuWidget | ( | ) | const |
Definition at line 326 of file qmainwindow.cpp.
References QWidget::layout(), QLayout::menuBar(), and menuBar().
Here is the call graph for this function:

| void QMainWindow::setMenuWidget | ( | QWidget * | menuBar | ) |
QMainWindow takes ownership of the menuBar pointer and deletes it at the appropriate time.
Definition at line 340 of file qmainwindow.cpp.
00341 { 00342 Q_D(QMainWindow); 00343 if (d->layout->menuBar() && d->layout->menuBar() != menuBar) 00344 delete d->layout->menuBar(); 00345 d->layout->setMenuBar(menuBar); 00346 }
Here is the call graph for this function:

| 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.
Definition at line 356 of file qmainwindow.cpp.
References QSizePolicy::Fixed, QSizePolicy::Ignored, and QWidget::layout().
Referenced by qdesigner_internal::QMainWindowContainer::addWidget(), TabbedBrowser::createHelpWindow(), MainWindow::createStatusBar(), TrWindow::danger(), MainWindow::fileSave(), TrWindow::findAgain(), MainWindow::loadFile(), Main::Main(), main(), MainWindow::MainWindow(), TrWindow::newPhraseBook(), TrWindow::nextUnfinished(), MainWindow::openFile(), TrWindow::openFile(), TrWindow::openPhraseBook(), TrWindow::prevUnfinished(), MainWindow::print(), TrWindow::print(), TrWindow::printPhraseBook(), PrintPreview::PrintPreview(), TrWindow::release(), TrWindow::releaseAs(), TrWindow::save(), MainWindow::saveFile(), HelpWindow::setSource(), MainWindow::setup(), HelpDialog::setupFullTextIndex(), HelpDialog::showInitDoneMessage(), TrWindow::showNewCurrent(), SpreadSheet::SpreadSheet(), HelpDialog::startSearch(), QDesignerWorkbench::switchToDockedMode(), TrWindow::TrWindow(), Main::updateStatus(), and SpreadSheet::updateStatus().
00357 { 00358 QStatusBar *statusbar = d_func()->layout->statusBar(); 00359 if (!statusbar) { 00360 QMainWindow *self = const_cast<QMainWindow *>(this); 00361 statusbar = new QStatusBar(self); 00362 statusbar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); 00363 self->setStatusBar(statusbar); 00364 } 00365 return statusbar; 00366 }
Here is the call graph for this function:

| void QMainWindow::setStatusBar | ( | QStatusBar * | statusbar | ) |
Sets the status bar for the main window to statusbar.
Setting the status bar to 0 will remove it from the main window. Note that QMainWindow takes ownership of the statusbar pointer and deletes it at the appropriate time.
Definition at line 377 of file qmainwindow.cpp.
References d.
Referenced by qdesigner_internal::QMainWindowContainer::addWidget(), and qdesigner_internal::QMainWindowContainer::remove().
00378 { 00379 Q_D(QMainWindow); 00380 if (d->layout->statusBar() && d->layout->statusBar() != statusbar) 00381 delete d->layout->statusBar(); 00382 d->layout->setStatusBar(statusbar); 00383 }
| QWidget * QMainWindow::centralWidget | ( | ) | const |
Returns the central widget for the main window. This function returns zero if the central widget has not been set.
Definition at line 392 of file qmainwindow.cpp.
References QWidget::layout().
Referenced by qdesigner_internal::QMainWindowContainer::addWidget(), qdesigner_internal::QMainWindowContainer::currentIndex(), QDesignerWorkbench::findFormWindow(), QDesignerWorkbench::findToolWindow(), qdesigner_internal::FormWindow::handleContextMenu(), qdesigner_internal::FormWindow::highlightWidget(), QDesignerDockWidget::inMainWindow(), qdesigner_internal::Layout::undoLayout(), and MainWindow::useComboBox().
Here is the call graph for this function:

| void QMainWindow::setCentralWidget | ( | QWidget * | widget | ) |
Sets the given widget to be the main window's central widget.
Note: QMainWindow takes ownership of the widget pointer and deletes it at the appropriate time.
Definition at line 403 of file qmainwindow.cpp.
References d.
Referenced by qdesigner_internal::QMainWindowContainer::addWidget(), ImageViewer::ImageViewer(), MainWindow::init(), QVFb::init(), Launcher::Launcher(), Main::Main(), main(), MainWindow::MainWindow(), PrintPreview::PrintPreview(), QDesignerActionEditor::QDesignerActionEditor(), QDesignerFormWindow::QDesignerFormWindow(), QDesignerObjectInspector::QDesignerObjectInspector(), QDesignerPropertyEditor::QDesignerPropertyEditor(), QDesignerResourceEditor::QDesignerResourceEditor(), QDesignerSignalSlotEditor::QDesignerSignalSlotEditor(), QDesignerWidgetBox::QDesignerWidgetBox(), MainWindow::setupViews(), MainWindow::setupWidgets(), SpreadSheet::SpreadSheet(), QDesignerWorkbench::switchToDockedMode(), and TextEdit::TextEdit().
00404 { 00405 Q_D(QMainWindow); 00406 if (d->layout->centralWidget() && d->layout->centralWidget() != widget) 00407 delete d->layout->centralWidget(); 00408 d->layout->setCentralWidget(widget); 00409 }
| void QMainWindow::setCorner | ( | Qt::Corner | corner, | |
| Qt::DockWidgetArea | area | |||
| ) |
Sets the given dock widget area to occupy the specified corner.
Definition at line 418 of file qmainwindow.cpp.
References Qt::BottomDockWidgetArea, Qt::BottomLeftCorner, Qt::BottomRightCorner, Qt::LeftDockWidgetArea, qWarning(), Qt::RightDockWidgetArea, Qt::TopDockWidgetArea, Qt::TopLeftCorner, and Qt::TopRightCorner.
Referenced by MainWindow::setCorner(), and TrWindow::TrWindow().
00419 { 00420 bool valid = false; 00421 switch (corner) { 00422 case Qt::TopLeftCorner: 00423 valid = (area == Qt::TopDockWidgetArea || area == Qt::LeftDockWidgetArea); 00424 break; 00425 case Qt::TopRightCorner: 00426 valid = (area == Qt::TopDockWidgetArea || area == Qt::RightDockWidgetArea); 00427 break; 00428 case Qt::BottomLeftCorner: 00429 valid = (area == Qt::BottomDockWidgetArea || area == Qt::LeftDockWidgetArea); 00430 break; 00431 case Qt::BottomRightCorner: 00432 valid = (area == Qt::BottomDockWidgetArea || area == Qt::RightDockWidgetArea); 00433 break; 00434 } 00435 if (!valid) 00436 qWarning("QMainWindow::setCorner(): 'area' is not valid for 'corner'"); 00437 else 00438 d_func()->layout->setCorner(corner, area); 00439 }
Here is the call graph for this function:

| Qt::DockWidgetArea QMainWindow::corner | ( | Qt::Corner | corner | ) | const |
Returns the dock widget area that occupies the specified corner.
Definition at line 447 of file qmainwindow.cpp.
00448 { return d_func()->layout->corner(corner); }
| void QMainWindow::addToolBarBreak | ( | Qt::ToolBarArea | area = Qt::TopToolBarArea |
) |
Adds a toolbar break to the given area after all the other objects that are present.
Definition at line 472 of file qmainwindow.cpp.
References checkToolBarArea().
Referenced by TextEdit::setupTextActions().
00473 { 00474 if (!checkToolBarArea(area, "QMainWindow::addToolBarBreak")) 00475 return; 00476 d_func()->layout->addToolBarBreak(area); 00477 }
Here is the call graph for this function:

| void QMainWindow::insertToolBarBreak | ( | QToolBar * | before | ) |
Inserts a toolbar break before the toolbar specified by before.
Definition at line 482 of file qmainwindow.cpp.
Referenced by QDesignerWorkbench::switchToTopLevelMode().
| 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). If the main window already manages toolbar then it will only move the toolbar to area.
Definition at line 493 of file qmainwindow.cpp.
References QToolBar::_q_updateIconSize(), QToolBar::_q_updateToolButtonStyle(), checkToolBarArea(), QObject::connect(), d, QObject::disconnect(), iconSizeChanged(), QToolBar::isAreaAllowed(), QWidget::isVisible(), qWarning(), SIGNAL, SLOT, and toolButtonStyleChanged().
Referenced by addToolBar(), qdesigner_internal::QMainWindowContainer::addWidget(), MainWindow::createToolBars(), Main::Main(), ToolBar::place(), PrintPreview::PrintPreview(), TextEdit::setupEditActions(), TextEdit::setupFileActions(), TextEdit::setupTextActions(), MainWindow::setupToolBar(), TrWindow::setupToolBars(), SpreadSheet::SpreadSheet(), QDesignerWorkbench::switchToDockedMode(), and QDesignerWorkbench::switchToTopLevelMode().
00494 { 00495 if (!checkToolBarArea(area, "QMainWindow::addToolBar")) 00496 return; 00497 00498 Q_D(QMainWindow); 00499 00500 if (!toolbar->isAreaAllowed(area)) 00501 qWarning("QMainWIndow::addToolBar(): specified 'area' is not an allowed for this toolbar"); 00502 00503 disconnect(this, SIGNAL(iconSizeChanged(QSize)), 00504 toolbar, SLOT(_q_updateIconSize(QSize))); 00505 disconnect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), 00506 toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); 00507 00508 d->layout->removeWidget(toolbar); 00509 00510 toolbar->d_func()->_q_updateIconSize(d->iconSize); 00511 toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); 00512 connect(this, SIGNAL(iconSizeChanged(QSize)), 00513 toolbar, SLOT(_q_updateIconSize(QSize))); 00514 connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), 00515 toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); 00516 00517 d->layout->addToolBar(area, toolbar); 00518 00519 if (isVisible()) 00520 d->layout->relayout(); 00521 }
Here is the call graph for this function:

| void QMainWindow::addToolBar | ( | QToolBar * | toolbar | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Equivalent of calling addToolBar(Qt::TopToolBarArea, toolbar)
Definition at line 526 of file qmainwindow.cpp.
References addToolBar(), and Qt::TopToolBarArea.
00527 { addToolBar(Qt::TopToolBarArea, toolbar); }
Here is the call graph for this function:

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Creates a QToolBar object, setting its window title to title, and inserts it into the top toolbar area.
Definition at line 537 of file qmainwindow.cpp.
References addToolBar(), and QWidget::setWindowTitle().
00538 { 00539 QToolBar *toolBar = new QToolBar(this); 00540 toolBar->setWindowTitle(title); 00541 addToolBar(toolBar); 00542 return toolBar; 00543 }
Here is the call graph for this function:

Inserts the toolbar into the area occupied by the before toolbar so that it appears before it. For example, in normal left-to-right layout operation, this means that toolbar will appear to the left of the toolbar specified by before in a horizontal toolbar area.
Definition at line 567 of file qmainwindow.cpp.
References QToolBar::_q_updateIconSize(), QToolBar::_q_updateToolButtonStyle(), QObject::connect(), d, iconSizeChanged(), QToolBar::isAreaAllowed(), QWidget::isVisible(), qt_remove_toolbar_from_layout(), SIGNAL, SLOT, toolBarArea(), and toolButtonStyleChanged().
00568 { 00569 Q_D(QMainWindow); 00570 Q_ASSERT_X(toolbar->isAreaAllowed(toolBarArea(before)), 00571 "QMainWIndow::insertToolBar", "specified 'area' is not an allowed area"); 00572 00573 qt_remove_toolbar_from_layout(toolbar, d); 00574 00575 toolbar->d_func()->_q_updateIconSize(d->iconSize); 00576 toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle); 00577 connect(this, SIGNAL(iconSizeChanged(QSize)), 00578 toolbar, SLOT(_q_updateIconSize(QSize))); 00579 connect(this, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)), 00580 toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle))); 00581 00582 d->layout->insertToolBar(before, toolbar); 00583 00584 if (isVisible()) 00585 d->layout->relayout(); 00586 }
Here is the call graph for this function:

| void QMainWindow::removeToolBar | ( | QToolBar * | toolbar | ) |
Removes the toolbar from the main window layout and hides it. Note that the toolbar is not deleted.
Definition at line 592 of file qmainwindow.cpp.
References qt_remove_toolbar_from_layout().
Referenced by qdesigner_internal::QMainWindowContainer::remove().
00593 { 00594 if (toolbar) { 00595 qt_remove_toolbar_from_layout(toolbar, d_func()); 00596 toolbar->hide(); 00597 } 00598 }
Here is the call graph for this function:

| Qt::ToolBarArea QMainWindow::toolBarArea | ( | QToolBar * | toolbar | ) | const |
Returns the Qt::ToolBarArea for toolbar. If toolbar has not been added to the main window, this function returns Qt::NoToolBarArea.
Definition at line 607 of file qmainwindow.cpp.
Referenced by insertToolBar(), and ToolBar::updateMenu().
| void QMainWindow::addDockWidget | ( | Qt::DockWidgetArea | area, | |
| QDockWidget * | dockwidget | |||
| ) |
Adds the given dockwidget to the specified area.
Definition at line 678 of file qmainwindow.cpp.
References Qt::BottomDockWidgetArea, checkDockWidgetArea(), QWidget::createWinId(), QWidget::hide(), Qt::Horizontal, QDockWidget::isAreaAllowed(), QWidget::isVisible(), qWarning(), QWidget::show(), Qt::TopDockWidgetArea, Qt::Vertical, and QWidget::window().
Referenced by qdesigner_internal::QMainWindowContainer::addWidget(), MainWindow::createDockWindows(), MainWindow::MainWindow(), ColorSwatch::place(), MainWindow::setupDockWidgets(), QDesignerWorkbench::switchToDockedMode(), and TrWindow::TrWindow().
00679 { 00680 if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) 00681 return; 00682 00683 if (!dockwidget->isAreaAllowed(area)) 00684 qWarning("QMainWindow::addDockWidget(): specified 'area' is not an allowed for this widget"); 00685 00686 Qt::Orientation orientation = Qt::Vertical; 00687 switch (area) { 00688 case Qt::TopDockWidgetArea: 00689 case Qt::BottomDockWidgetArea: 00690 orientation = Qt::Horizontal; 00691 break; 00692 default: 00693 break; 00694 } 00695 d_func()->layout->removeWidget(dockwidget); // in case it was already in here 00696 addDockWidget(area, dockwidget, orientation); 00697 00698 #ifdef Q_WS_MAC //drawer support 00699 extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp 00700 if (qt_mac_is_macdrawer(dockwidget)) { 00701 extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp 00702 window()->createWinId(); 00703 dockwidget->window()->createWinId(); 00704 qt_mac_set_drawer_preferred_edge(dockwidget, area); 00705 if (dockwidget->isVisible()) { 00706 dockwidget->hide(); 00707 dockwidget->show(); 00708 } 00709 } 00710 #endif 00711 }
Here is the call graph for this function:

| void QMainWindow::addDockWidget | ( | Qt::DockWidgetArea | area, | |
| QDockWidget * | dockwidget, | |||
| Qt::Orientation | orientation | |||
| ) |
Adds dockwidget into the given area in the direction specified by the orientation.
Definition at line 717 of file qmainwindow.cpp.
References checkDockWidgetArea(), QDockWidget::isAreaAllowed(), QWidget::isVisible(), and qWarning().
00719 { 00720 if (!checkDockWidgetArea(area, "QMainWindow::addDockWidget")) 00721 return; 00722 00723 if (!dockwidget->isAreaAllowed(area)) 00724 qWarning("QMainWindow::addDockWidget(): specified 'area' is not an allowed for this widget"); 00725 00726 // add a window to an area, placing done relative to the previous 00727 d_func()->layout->addDockWidget(area, dockwidget, orientation); 00728 if (isVisible()) 00729 d_func()->layout->relayout(); 00730 }
Here is the call graph for this function:

| void QMainWindow::splitDockWidget | ( | QDockWidget * | first, | |
| QDockWidget * | second, | |||
| Qt::Orientation | orientation | |||
| ) |
Splits the space covered by the first dock widget into two parts, moves the first dock widget into the first part, and moves the second dock widget into the second part.
The orientation specifies how the space is divided: A Qt::Horizontal split places the second dock widget to the right of the first; a Qt::Vertical split places the second dock widget below the first.
Note: if first is currently in a tabbed docked area, second will be added as a new tab, not as a neighbor of first. This is because a single tab can contain only one dock widget.
Note: The Qt::LayoutDirection influences the order of the dock widgets in the two parts of the divided area. When right-to-left layout direction is enabled, the placing of the dock widgets will be reversed.
Definition at line 753 of file qmainwindow.cpp.
References dockWidgetArea(), QDockWidget::isAreaAllowed(), QWidget::isVisible(), and qWarning().
Referenced by ColorSwatch::splitInto().
00755 { 00756 if (!dockwidget->isAreaAllowed(dockWidgetArea(after))) 00757 qWarning("QMainWindow::splitDockWidget(): specified 'area' is not an allowed for this widget"); 00758 d_func()->layout->splitDockWidget(after, dockwidget, orientation); 00759 if (isVisible()) 00760 d_func()->layout->relayout(); 00761 }
Here is the call graph for this function:

| void QMainWindow::tabifyDockWidget | ( | QDockWidget * | first, | |
| QDockWidget * | second | |||
| ) |
Moves second dock widget on top of first dock widget, creating a tabbed docked area in the main window.
Definition at line 769 of file qmainwindow.cpp.
References dockWidgetArea(), QDockWidget::isAreaAllowed(), QWidget::isVisible(), and qWarning().
Referenced by ColorSwatch::tabInto().
00770 { 00771 if (!second->isAreaAllowed(dockWidgetArea(first))) 00772 qWarning("QMainWindow::splitDockWidget(): specified 'area' is not an allowed for this widget"); 00773 d_func()->layout->tabifyDockWidget(first, second); 00774 if (isVisible()) 00775 d_func()->layout->relayout(); 00776 }
Here is the call graph for this function:

| void QMainWindow::removeDockWidget | ( | QDockWidget * | dockwidget | ) |
Removes the dockwidget from the main window layout and hides it. Note that the dockwidget is not deleted.
Definition at line 782 of file qmainwindow.cpp.
References QWidget::hide().
Referenced by qdesigner_internal::QMainWindowContainer::remove().
00783 { 00784 if (dockwidget) { 00785 d_func()->layout->removeWidget(dockwidget); 00786 dockwidget->hide(); 00787 } 00788 }
| Qt::DockWidgetArea QMainWindow::dockWidgetArea | ( | QDockWidget * | dockwidget | ) | const |
Returns the Qt::DockWidgetArea for dockwidget. If dockwidget has not been added to the main window, this function returns Qt::NoDockWidgetArea.
Definition at line 797 of file qmainwindow.cpp.
Referenced by splitDockWidget(), tabifyDockWidget(), and ColorSwatch::updateContextMenu().
| QByteArray QMainWindow::saveState | ( | int | version = 0 |
) | const |
Saves the current state of this mainwindow's toolbars and dockwidgets. The version number is stored as part of the data.
The objectName property is used to identify each QToolBar and QDockWidget. You should make sure that this property is unique for each QToolBar and QDockWidget you add to the QMainWindow
To restore the saved state, pass the return value and version number to restoreState().
Definition at line 816 of file qmainwindow.cpp.
References data, QTest::stream, QMainWindowLayout::VersionMarker, and QIODevice::WriteOnly.
Referenced by MainWindow::saveLayout(), MainWindow::saveSettings(), QDesignerWorkbench::switchToNeutralMode(), TrWindow::writeConfig(), and QDesignerWorkbench::~QDesignerWorkbench().
00817 { 00818 QByteArray data; 00819 QDataStream stream(&data, QIODevice::WriteOnly); 00820 stream << QMainWindowLayout::VersionMarker; 00821 stream << version; 00822 d_func()->layout->saveState(stream); 00823 return data; 00824 }
| bool QMainWindow::restoreState | ( | const QByteArray & | state, | |
| int | version = 0 | |||
| ) |
Restores the state of this mainwindow's toolbars and dockwidgets. 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.
Definition at line 835 of file qmainwindow.cpp.
References QByteArray::isEmpty(), QWidget::isVisible(), marker, QDataStream::Ok, QCoreApplication::postEvent(), QIODevice::ReadOnly, QWidget::size(), QTest::stream, and QMainWindowLayout::VersionMarker.
Referenced by MainWindow::loadLayout(), MainWindow::MainWindow(), TrWindow::readConfig(), and QDesignerWorkbench::switchToDockedMode().
00836 { 00837 if (state.isEmpty()) 00838 return false; 00839 QByteArray sd = state; 00840 QDataStream stream(&sd, QIODevice::ReadOnly); 00841 int marker, v; 00842 stream >> marker; 00843 stream >> v; 00844 if (stream.status() != QDataStream::Ok || marker != QMainWindowLayout::VersionMarker || v != version) 00845 return false; 00846 bool restored = d_func()->layout->restoreState(stream); 00847 if (isVisible()) 00848 QApplication::postEvent(this, new QResizeEvent(size(), size())); 00849 return restored; 00850 }
Here is the call graph for this function:

| QMenu * QMainWindow::createPopupMenu | ( | ) | [virtual] |
Returns a popup menu containing checkable entries for the toolbars and dock widgets present in the main window.
By default, this function is called by the main window when the user activates a context menu, typically by right-clicking on a toolbar or a dock widget.
If you want to create a custom popup menu, reimplement this function and return a newly-created popup menu. Ownership of the popup menu is transferred to the caller.
Definition at line 1073 of file qmainwindow.cpp.
References QMenu::addAction(), QMenu::addSeparator(), QList< T >::at(), d, i, QList< T >::size(), QToolBar::toggleViewAction(), and QDockWidget::toggleViewAction().
Referenced by contextMenuEvent(), and MainWindow::setup().
01074 { 01075 Q_D(QMainWindow); 01076 QMenu *menu = 0; 01077 #ifndef QT_NO_DOCKWIDGET 01078 QList<QDockWidget *> dockwidgets = qFindChildren<QDockWidget *>(this); 01079 if (dockwidgets.size()) { 01080 menu = new QMenu(this); 01081 for (int i = 0; i < dockwidgets.size(); ++i) { 01082 QDockWidget *dockWidget = dockwidgets.at(i); 01083 if (dockWidget->parentWidget() == this 01084 && d->layout->contains(dockWidget)) { 01085 menu->addAction(dockwidgets.at(i)->toggleViewAction()); 01086 } 01087 } 01088 menu->addSeparator(); 01089 } 01090 #endif // QT_NO_DOCKWIDGET 01091 #ifndef QT_NO_TOOLBAR 01092 QList<QToolBar *> toolbars = qFindChildren<QToolBar *>(this); 01093 if (toolbars.size()) { 01094 if (!menu) 01095 menu = new QMenu(this); 01096 for (int i = 0; i < toolbars.size(); ++i) { 01097 QToolBar *toolBar = toolbars.at(i); 01098 if (toolBar->parentWidget() == this 01099 && d->layout->contains(toolBar)) { 01100 menu->addAction(toolbars.at(i)->toggleViewAction()); 01101 } 01102 } 01103 } 01104 #endif 01105 Q_UNUSED(d); 01106 return menu; 01107 }
Here is the call graph for this function:

| void QMainWindow::setAnimated | ( | bool | enabled | ) | [slot] |
| void QMainWindow::setDockNestingEnabled | ( | bool | enabled | ) | [slot] |
| void QMainWindow::iconSizeChanged | ( | const QSize & | iconSize | ) | [signal] |
This signal is emitted when the size of the icons used in the window is changed. The new icon size is passed in iconSize.
You can connect this signal to other components to help maintain a consistent appearance for your application.
Referenced by addToolBar(), insertToolBar(), and setIconSize().
| void QMainWindow::toolButtonStyleChanged | ( | Qt::ToolButtonStyle | toolButtonStyle | ) | [signal] |
This signal is emitted when the style used for tool buttons in the window is changed. The new style is passed in toolButtonStyle.
You can connect this signal to other components to help maintain a consistent appearance for your application.
Referenced by addToolBar(), insertToolBar(), and setToolButtonStyle().
| void QMainWindow::contextMenuEvent | ( | QContextMenuEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 1018 of file qmainwindow.cpp.
References QWidget::childAt(), createPopupMenu(), event(), QMenu::exec(), QWidget::parentWidget(), and tb.
01019 { 01020 // only show the context menu for direct QDockWidget and QToolBar 01021 // children 01022 QWidget *child = childAt(event->pos()); 01023 while (child && child != this) { 01024 #ifndef QT_NO_DOCKWIDGET 01025 if (QDockWidget *dw = qobject_cast<QDockWidget *>(child)) { 01026 if (dw->parentWidget() != this) 01027 return; 01028 if (dw->widget() 01029 && dw->widget()->geometry().contains(child->mapFrom(this, event->pos()))) { 01030 // ignore the event if the mouse is over the QDockWidget contents 01031 return; 01032 } 01033 break; 01034 } 01035 #endif // QT_NO_DOCKWIDGET 01036 #ifndef QT_NO_TOOLBAR 01037 if (QToolBar *tb = qobject_cast<QToolBar *>(child)) { 01038 if (tb->parentWidget() != this) 01039 return; 01040 break; 01041 } 01042 #endif 01043 child = child->parentWidget(); 01044 } 01045 if (child == this) 01046 return; 01047 01048 #ifndef QT_NO_MENU 01049 QMenu *popup = createPopupMenu(); 01050 if (!popup) 01051 return; 01052 popup->exec(event->globalPos()); 01053 delete popup; 01054 event->accept(); 01055 #endif 01056 }
Here is the call graph for this function:

| bool QMainWindow::event | ( | QEvent * | event | ) | [protected, virtual] |
Reimplemented from QWidget.
Definition at line 900 of file qmainwindow.cpp.
References QEvent::accept(), QList< T >::at(), QMouseEvent::button(), QMouseEvent::buttons(), d, QWidget::event(), QEvent::HoverLeave, QEvent::HoverMove, i, QEvent::LayoutRequest, Qt::LeftButton, QWidget::minimumSize(), QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseMove, p, QEvent::Paint, QMouseEvent::pos(), QWidget::pos(), QWidget::resize(), QCoreApplication::sendPostedEvents(), setIconSize(), QWidget::setVisible(), QList< T >::size(), QWidget::size(), QEvent::StatusTip, QEvent::StyleChange, and QEvent::ToolBarChange.
Referenced by Launcher::closeEvent(), contextMenuEvent(), Launcher::resizeEvent(), and QDesignerPropertyEditor::showEvent().
00901 { 00902 Q_D(QMainWindow); 00903 switch (event->type()) { 00904 00905 #ifndef QT_NO_DOCKWIDGET 00906 case QEvent::Paint: { 00907 QPainter p(this); 00908 QRegion r = static_cast<QPaintEvent*>(event)->region(); 00909 d->layout->dockWidgetLayout.paintSeparators(&p, this, r, d->hoverPos); 00910 break; 00911 } 00912 00913 #ifndef QT_NO_CURSOR 00914 case QEvent::HoverMove: { 00915 d->adjustCursor(static_cast<QHoverEvent*>(event)->pos()); 00916 break; 00917 } 00918 00919 case QEvent::HoverLeave: 00920 d->adjustCursor(QPoint(0, 0)); 00921 break; 00922 #endif // QT_NO_CURSOR 00923 00924 case QEvent::MouseButtonPress: { 00925 QMouseEvent *e = static_cast<QMouseEvent*>(event); 00926 if (e->button() == Qt::LeftButton && d->layout->startSeparatorMove(e->pos())) { 00927 // The click was on a separator, eat this event 00928 e->accept(); 00929 return true; 00930 } 00931 break; 00932 } 00933 00934 case QEvent::MouseMove: { 00935 QMouseEvent *e = static_cast<QMouseEvent*>(event); 00936 00937 #ifndef QT_NO_CURSOR 00938 d->adjustCursor(e->pos()); 00939 #endif 00940 if (e->buttons() & Qt::LeftButton) { 00941 if (d->layout->separatorMove(e->pos())) { 00942 // We're moving a separator, eat this event 00943 e->accept(); 00944 return true; 00945 } 00946 } 00947 00948 break; 00949 } 00950 00951 case QEvent::MouseButtonRelease: { 00952 QMouseEvent *e = static_cast<QMouseEvent*>(event); 00953 if (d->layout->endSeparatorMove(e->pos())) { 00954 // We've released a separator, eat this event 00955 e->accept(); 00956 return true; 00957 } 00958 break; 00959 } 00960 00961 #endif 00962 00963 #ifndef QT_NO_TOOLBAR 00964 case QEvent::ToolBarChange: { 00965 QList<QToolBar *> toolbars = qFindChildren<QToolBar *>(this); 00966 QSize minimumSize = d->layout->minimumSize(); 00967 for (int i = 0; i < toolbars.size(); ++i) { 00968 QToolBar *toolbar = toolbars.at(i); 00969 toolbar->setVisible(!toolbar->isVisible()); 00970 } 00971 QApplication::sendPostedEvents(this, QEvent::LayoutRequest); 00972 QSize newMinimumSize = d->layout->minimumSize(); 00973 QSize delta = newMinimumSize - minimumSize; 00974 resize(size() + delta); 00975 return true; 00976 } 00977 #endif 00978 00979 #ifndef QT_NO_STATUSTIP 00980 case QEvent::StatusTip: 00981 #ifndef QT_NO_STATUSBAR 00982 if (QStatusBar *sb = d->layout->statusBar()) 00983 sb->showMessage(static_cast<QStatusTipEvent*>(event)->tip()); 00984 else 00985 #endif 00986 static_cast<QStatusTipEvent*>(event)->ignore(); 00987 return true; 00988 #endif // QT_NO_STATUSTIP 00989 00990 case QEvent::StyleChange: 00991 if (!d->explicitIconSize) 00992 setIconSize(QSize()); 00993 break; 00994 00995 default: 00996 break; 00997 } 00998 00999 return QWidget::event(event); 01000 }
Here is the call graph for this function:

1.5.1