![]() |
Home · Overviews · Examples |
This example is an extension to the window created in Chapter 1. We now go on to make the application quit properly when the user tells it to.
This connect() call establishes a one-way connection between two Qt objects (objects that inherit QObject, directly or indirectly). Every Qt object can have both signals (to send messages) and slots (to receive messages). All widgets are Qt objects, since they inherit QWidget, which in turn inherits QObject.
Here, the clicked() signal of quit is connected to the quit() slot of app, so that when the button is clicked, the application quits.
The Signals and Slots documentation describes this topic in detail. See Chapter 1 for how to create a makefile and build the application. Are there any other signals in QPushButton you can connect to quit? [Hint: The QPushButton inherits most of its functionality from QAbstractButton.]Running the Application
When you run this program, you will see an even smaller window than in Chapter 1, filled with an even smaller button. Exercises
Try to resize the window. Press the button to close the application.
Copyright © 2008 Trolltech
Trademarks