Qt GUI Widgets

Table of contents:

This chapter provides an overview of the GUI building blocks, called widgets, that are part of the Qt library and includes some simple examples of how to use them.

11.1

Widget Categories

239

11.2

QMainWindow and QSettings

240

11.3

Dialogs

244

11.4

Images and Resources

248

11.5

Layout of Widgets

251

11.6

QActions, QMenus, and QMenuBars

260

11.7

QActions, QToolbars, and QActionGroups

262

11.8

Regions and QDockWidgets

270

11.9

Views of a QStringList

272

Widgets, objects of classes derived from QWidget, are reusable building blocks with a visual representation on the screen. The common features of a QWidget are shown in Figure 11.1.

Figure 11.1. QWidget's Heritage

QWidget is a class that uses multiple inheritance (see Section 23.3). A QWidget is a QObject, and thus can have parents, signals, slots, and managed children. A QWidget is a QPaintDevice, the base class of all objects that can be "painted."

QWidgets interact with their children in interesting ways. A widget that has no parent is called a window. If one widget is a parent of another widget, the boundaries of the child widget lie completely within the boundaries of the parent. The contained child widget is displayed according to layout rules (see Section 11.5).

A QWidget can handle events by responding to signals from various entities in the window system (e.g., mouse, keyboard, other processes, etc.). It can paint its own rectangular image on the screen. It can remove itself from the screen in a way that respects whatever else is on the screen at the moment.

A typical desktop GUI application can contain many (hundreds is not unusual) different QWidget-derived objects, deployed according to parent-child relationships and arranged according to the specifications of the applicable layouts.

A QWidget is considered to be the simplest of all GUI classes, because it is rendered as an empty box. The class itself is quite complex, containing hundreds of functions. When you reuse QWidget and its subclasses you are standing on the shoulders of giants, because every QWidget is built on top of layers of Qt code, which in turn are built on top of different layers of native widget libraries, depending on your platform (X11 in Linux, Cocoa on MacOS, and Win32 in Windows).

In fact, QWidget is a Façade for the widget classes from each of these native window libraries (see Section 16.3).


Widget Categories

Part I: Introduction to C++ and Qt 4

C++ Introduction

Classes

Introduction to Qt

Lists

Functions

Inheritance and Polymorphism

Part II: Higher-Level Programming

Libraries

Introduction to Design Patterns

QObject

Generics and Containers

Qt GUI Widgets

Concurrency

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

Bibliography

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

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net