Skip to Content
Programming with Qt, 2nd Edition
book

Programming with Qt, 2nd Edition

by Matthias Kalle Dalheimer
January 2002
Beginner to intermediate
522 pages
14h 36m
English
O'Reilly Media, Inc.
Content preview from Programming with Qt, 2nd Edition

Appendix A. Answers to Exercises

Answers to Exercises in Chapter 2

Answers to Exercises in the Section “Hello, world!”

  1. Of course, there is not much to write here. The actual commands to compile Qt applications are indicated in the “Hello, world!” section. Try some of the example programs from the Qt distribution first.

Answers to Exercises in the Section “Using the Qt Reference Documentation”

  1. You can find the documentation for QApplication in html/qapplication.html in your Qt installation.

  2. QFrame is derived from QWidget. Other classes in Qt derived from QFrame are QDockWindow, QGrid, QGroupBox, QHBox, QLCDNumber, QLabel, QLineEdit, QMenuBar, QPopupMenu, QProgressBar, QScrollView, QSplitter, and QWidgetStack.

    Since QLabel inherits from QFrame, all public and protected methods of QFrame, including setFrameStyle(), are available for QLabel objects. You can see all methods available in a class (including those inherited from base classes) in the “List of all member functions” section of the class documentation.

Answers to Exercises in the Section “Adding an Exit Button”

  1. The following code adds another button. There is nothing new here. Note that we have also increased the size of the top-level widget to accommodate the additional widget.

    #include <qapplication.h> #include <qlabel.h> #include <qpushbutton.h> int main( int argc, char* argv[] ) { QApplication myapp( argc, argv ); QWidget* mywidget = new QWidget(); mywidget->setGeometry( 400, 300, 120, 130 ); QPushButton* anotherquitbutton = new ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ GUI Programming with Qt 4

C++ GUI Programming with Qt 4

Jasmin Blanchette, Mark Summerfield
C++ GUI Programming with Qt 4

C++ GUI Programming with Qt 4

Jasmin Blanchette, Mark Summerfield

Publisher Resources

ISBN: 0596000642Supplemental ContentErrata Page