Chapter 10: Main Windows and Actions

Most QApplications manage a single QMainWindow. As Figure 10.1 shows, the QMainWindow has some features that are common to most desktop applications:

• Central widget

• Menu bar

• Toolbars

• Status bar

• Dock regions

Figure 10.1 A Main Window

image

In most applications, the QMainWindow is the (grand)parent object of all QAction, QWidget, and QObject heap objects. It is common practice to extend that class for applications, as shown in Example 10.1.

Example 10.1 src/widgets/mainwindow/mymainwindow.h

image

10.1 QActions, ...

Get Introduction to Design Patterns in C++ with Qt, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.