Regions and QDockWidgets

Table of contents:

Any class that derives from QMainWindow has four dock window regions, one on each of the four sides of the central widget. These four regions are used for attaching secondary 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 it is set, a QDockWidget can be undocked, resized, dragged to a different location, or docked to the same or to a different dock window region by the end user.

The QMainWindow correctly creates the slidable QSplitters between the central widget and the QDockWidgets. The two principal QMainWindow functions for managing the dock window regions are

  1. setCentralWidget(QWidget*), which establishes the central widget
  2. addDockWidget(Qt::DockWidgetAreas, QDockWidget*), which adds the given QDockWidget to the specified dock window region.

DockWindows are very important in integrated development environments, because different tools or views are needed in different situations. Each view is a widget, and they can all be "plugged" into the main window quite easily with the docking mechanism as shown in Figure 11.8.

Figure 11.8. Dragged DockWindows

Like most KDE applications, kdbg, the stand-alone KDE debugger, makes use of DockWindows. kdbg has a source code window (central widget) and dockable views for things such as:

  • Program stack
  • Output
  • Watches
  • Local variables
  • Threads

These widgets do not all need to be visible at the same time, so there is a View menu that lets you select or de-select all of the different views. QMainWindow::createPopupMenu() returns this menu, permitting you to add it to toolbars or other pull-down menus.

Views of a QStringList

Part I: Introduction to C++ and Qt 4

C++ Introduction


Introduction to Qt



Inheritance and Polymorphism

Part II: Higher-Level Programming


Introduction to Design Patterns


Generics and Containers

Qt GUI Widgets


Validation and Regular Expressions

Parsing XML

Meta Objects, Properties, and Reflective Programming

More Design Patterns

Models and Views

Qt SQL Classes

Part III: C++ Language Reference

Types and Expressions

Scope and Storage Class

Statements and Control Structures

Memory Access

Chapter Summary

Inheritance in Detail

Miscellaneous Topics

Part IV: Programming Assignments

MP3 Jukebox Assignments

Part V: Appendices

MP3 Jukebox Assignments


MP3 Jukebox Assignments

An Introduction to Design Patterns in C++ with Qt 4
An Introduction to Design Patterns in C++ with Qt 4
ISBN: 0131879057
EAN: 2147483647
Year: 2004
Pages: 268 © 2008-2020.
If you may any questions please contact us: