[ fromfile: mainwindows.xml id: dockwindows ]
Any class that derives from QMainWindow has dock window regions, one on each of the four sides of the central widget, as shown in Figure 10.6. These regions are used for attaching secondary windows, also called dock windows, to the central widget.
A QDockWidget can be thought of as an envelope for another widget. It has a title bar and a content area to contain the other widget. Depending on how its attributes are set, a QDockWidget can be undocked (so that it "floats"), resized, closed, dragged to a different location, or docked to the same or to a different dock widget region by the end user. It's okay to have several dockwidgets occupying the same dock region.
The QMainWindow correctly creates slidable QSplitters between the central widget and the QDockWidgets. The two principal QMainWindow functions for managing the dock widget regions are
setCentralWidget(QWidget*)
,
which establishes the central widget.
addDockWidget(Qt::DockWidgetAreas, QDockWidget*)
,
which adds the given QDockWidget to the specified
dock window region.
Dock windows are important in integrated development environments because different tools or views are needed in different situations. Each dock window is a widget that can be "plugged" into the main window quite easily with the docking mechanism, as shown in Figure 10.7.
Like most Qt applications, Designer, the tool for designing and building GUIs, makes heavy use of dock windows. Designer has a widget editor (central widget) and dockable views for tools such as
Widget Box
Object Inspector
Proeprty Editor
Signal/Slot Editor
Action Editor
Resource Editor
These dockables do not all need to be visible at the same time, so there is a View menu that enables you to select
or deselect them as needed.
QMainWindow::createPopupMenu()
returns this menu, permitting you use it from context menus, or add it to toolbars or to pull-down menus.
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |