source: trunk/doc/src/declarative/qmlruntime.qdoc@ 1036

Last change on this file since 1036 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: 4.6 KB
RevLine 
[844]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\page qmlruntime.html
30\title Qt Declarative UI Runtime
31
32QML documents are loaded and executed by the QML runtime. This includes the
33Declarative UI engine along with the built-in QML elements and plugin modules,
34and it also provides access to third-party QML elements and modules.
35
36Applications that use QML need to invoke the QML runtime in order to
37execute QML documents. This can be done by creating a QDeclarativeView
38or a QDeclarativeEngine, as described below. In addition, the Declarative UI
39package includes the \QQV tool, which loads \c .qml files. This tool is
40useful for developing and testing QML code without the need to write
41a C++ application to load the QML runtime.
42
43
44
45\section1 Deploying QML-based applications
46
47To deploy an application that uses QML, the QML runtime must be invoked by
48the application. This is done by writing a Qt C++ application that loads the
49QDeclarativeEngine by either:
50
51\list
52\o Loading the QML file through a QDeclarativeView instance, or
53\o Creating a QDeclarativeEngine instance and loading QML files with QDeclarativeComponent
54\endlist
55
56
57\section2 Deploying with QDeclarativeView
58
59QDeclarativeView is a QWidget-based class that is able to load QML files.
60For example, if there is a QML file, \c application.qml, like this:
61
62\qml
63 import QtQuick 1.0
64
65 Rectangle { width: 100; height: 100; color: "red" }
66\endqml
67
68It can be loaded in a Qt application's \c main.cpp file like this:
69
70\code
71 #include <QApplication>
72 #include <QDeclarativeView>
73
74 int main(int argc, char *argv[])
75 {
76 QApplication app(argc, argv);
77
78 QDeclarativeView view;
79 view.setSource(QUrl::fromLocalFile("application.qml"));
80 view.show();
81
82 return app.exec();
83 }
84\endcode
85
86This creates a QWidget-based view that displays the contents of
87\c application.qml.