doc/src/examples/worldtimeclockbuilder.qdoc
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the documentation of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 /*!
       
    43   \example designer/worldtimeclockbuilder
       
    44   \title World Time Clock Builder Example
       
    45 
       
    46   The World Time Clock Builder example shows how forms created with Qt
       
    47   Designer that contain custom widgets can be dynamically generated at
       
    48   run-time.
       
    49 
       
    50   \image worldtimeclockbuilder-example.png
       
    51 
       
    52   This example uses a form containing the custom widget plugin described in the
       
    53   \l{designer/worldtimeclockplugin}{World Time Clock Plugin} example, and
       
    54   dynamically generates a user interface using the QUiLoader class, part of
       
    55   the QtUiTools module.
       
    56 
       
    57   \section1 Preparation
       
    58 
       
    59   As with the \l{designer/calculatorbuilder}{Calculator Builder} example, the
       
    60   project file for this example needs to include the appropriate definitions
       
    61   to ensure that it is built against the required Qt modules.
       
    62 
       
    63   \snippet examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.pro 0
       
    64 
       
    65   By appending \c form to the \c CONFIG declaration, we instruct \c qmake to
       
    66   generate a dependency on the \c libQtUiTools library containing the QtUiTools
       
    67   classes.
       
    68 
       
    69   Note that we do not inform \c qmake about any UI files, and so none will
       
    70   be processed and built into the application. The resource file contains
       
    71   an entry for the particular form that we wish to use:
       
    72 
       
    73   \quotefile examples/designer/worldtimeclockbuilder/worldtimeclockbuilder.qrc
       
    74 
       
    75   Forms do not need to be included with the application in this way. We only
       
    76   include a form in the application's resources for convenience, and to keep
       
    77   the example short.
       
    78 
       
    79   \section1 Loading and Building the Form
       
    80 
       
    81   Since this example only loads and displays a pre-prepared form, all of the
       
    82   work can be done in the main() function. We are using a class from the
       
    83   QtUiTools library so, in addition to any other Qt classes that are normally
       
    84   required to write an application, we must include the appropriate header
       
    85   file:
       
    86 
       
    87   \snippet examples/designer/worldtimeclockbuilder/main.cpp 0
       
    88 
       
    89   The main function initializes the resource system with the Q_INIT_RESOURCE()
       
    90   macro and constructs an QApplication instance in the usual way:
       
    91 
       
    92   \snippet examples/designer/worldtimeclockbuilder/main.cpp 1
       
    93 
       
    94   We construct a QUiLoader object to handle the form we want to use.
       
    95 
       
    96   The form itself is obtained from the resource file system using the path
       
    97   defined in the resource file. We use the form loader to load and construct
       
    98   the form:
       
    99 
       
   100   \snippet examples/designer/worldtimeclockbuilder/main.cpp 2
       
   101 
       
   102   Once the form has been loaded, the resource file can be closed and the
       
   103   widget is shown.
       
   104 
       
   105   \snippet examples/designer/worldtimeclockbuilder/main.cpp 3
       
   106 
       
   107   The form loader ensures that all the signal and slot connections between
       
   108   objects in the form are set up correctly when the form is loaded. As a
       
   109   result, the time is updated by the World Time Clock widget, and the time
       
   110   zone spin box can be used to change the position of the hour hand.
       
   111 */