source: trunk/doc/src/examples/worldtimeclockbuilder.qdoc@ 1168

Last change on this file since 1168 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 3.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29 \example designer/worldtimeclockbuilder
30 \title World Time Clock Builder Example
31
32 The World Time Clock Builder example shows how forms created with Qt
33 Designer that contain custom widgets can be dynamically generated at
34 run-time.
35
36 \image worldtimeclockbuilder-example.png
37
38 This example uses a form containing the custom widget plugin described in the
39 \l{designer/worldtimeclockplugin}{World Time Clock Plugin} example, and
40 dynamically generates a user interface using the QUiLoader class, part of
41 the QtUiTools module.
42
43 \section1 Preparation
44
45 As with the \l{designer/calculatorbuilder}{Calculator Builder} example, the
46 project file for this example needs to include the appropriate definitions
47 to ensure that it is built against the required Qt modules.
48
49 \snippet examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro 0
50
51 By appending \c form to the \c CONFIG declaration, we instruct \c qmake to
52 generate a dependency on the \c libQtUiTools library containing the QtUiTools
53 classes.
54
55 Note that we do not inform \c qmake about any UI files, and so none will
56 be processed and built into the application. The resource file contains
57 an entry for the particular form that we wish to use:
58
59 \quotefile examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc
60
61 Forms do not need to be included with the application in this way. We only
62 include a form in the application's resources for convenience, and to keep
63 the example short.
64
65 \section1 Loading and Building the Form
66
67 Since this example only loads and displays a pre-prepared form, all of the
68 work can be done in the main() function. We are using a class from the
69 QtUiTools library so, in addition to any other Qt classes that are normally
70 required to write an application, we must include the appropriate header
71 file:
72
73 \snippet examples/designer/worldtimeclockbuilder/main.cpp 0
74
75 The main function initializes the resource system with the Q_INIT_RESOURCE()
76 macro and constructs an QApplication instance in the usual way:
77
78 \snippet examples/designer/worldtimeclockbuilder/main.cpp 1
79
80 We construct a QUiLoader object to handle the form we want to use.
81
82 The form itself is obtained from the resource file system using the path
83 defined in the resource file. We use the form loader to load and construct
84 the form:
85
86 \snippet examples/designer/worldtimeclockbuilder/main.cpp 2
87
88 Once the form has been loaded, the resource file can be closed and the
89 widget is shown.
90
91 \snippet examples/designer/worldtimeclockbuilder/main.cpp 3
92
93 The form loader ensures that all the signal and slot connections between
94 objects in the form are set up correctly when the form is loaded. As a
95 result, the time is updated by the World Time Clock widget, and the time
96 zone spin box can be used to change the position of the hour hand.
97*/
Note: See TracBrowser for help on using the repository browser.