Files:
If a widget is created without a parent, it is treated as a window, or top-level widget, when it is shown. Since it has no parent object to ensure that it is deleted when no longer needed, it is up to the developer to keep track of the top-level widgets in an application.
In the following example, we use QWidget to create and show a window with a default size:
#include <QtGui> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.resize(320, 240); window.show(); window.setWindowTitle( QApplication::translate("toplevel", "Top-level widget")); return app.exec(); } |
To create a real GUI, we need to place widgets inside the window. To do this, we pass a QWidget instance to a widget's constructor, as we will demonstrate in the next part of this tutorial.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.