diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-12-30 13:04:38 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-12-30 13:04:38 (GMT) |
commit | d280dcda3fc8ec2ae99641c95bc64823652b9f86 (patch) | |
tree | 23a2f956c041934df58ad05ce42a9c9649766cca /doc | |
parent | 411e60e45a779d8c80e70daee2bff9a1306f98db (diff) | |
download | Qt-d280dcda3fc8ec2ae99641c95bc64823652b9f86.zip Qt-d280dcda3fc8ec2ae99641c95bc64823652b9f86.tar.gz Qt-d280dcda3fc8ec2ae99641c95bc64823652b9f86.tar.bz2 |
Add documentation for integrating with existing Qt UI code
Diffstat (limited to 'doc')
-rw-r--r-- | doc/src/declarative/integrating.qdoc | 90 | ||||
-rw-r--r-- | doc/src/declarative/qtprogrammers.qdoc | 3 |
2 files changed, 92 insertions, 1 deletions
diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc new file mode 100644 index 0000000..fd3b9f7 --- /dev/null +++ b/doc/src/declarative/integrating.qdoc @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qml-integration.html +\title Integrating QML with existing Qt UI code + +If you have existing Qt UI code which does not use QML, you can still +use QML in some ways without having to rewrite your UI. + +\section1 Adding QML to a QWidget based UI +If you have an existing QWidget based UI you can simply write new custom +widgets in QML. To integrate them into your application you can create a +QmlView widget, and load the QML file into that. You'll then have a new widget +containing your declarative UI, and you can interact with it through the +QmlView interface. The one drawback of this approach is that QmlView is a lot +heavier than a QWidget in terms of memory consumption and initialization speed, +and so having large numbers of them may lead to performance degredation. + +For a smooth transition from a QWidget based UI to a QML based UI, simply +rewrite your widgets in QML one at a time, using the above method. When +all of your widgets are written in QML you can rewrite your main widget in +QML, so as to load the other widgets in QML instead of using QmlViews. Then +you just load the main QML file on startup. + +Keep in mind that QWidgets were designed for different sorts of UIs than QML +was, and so it is not always a good idea to switch. QWidgets are a better +choice if your UI is comprised of a small number of complex and static +elements, and QML is a better choice if your UI is comprised of a large number +of simple and dynamic elements. + +\section1 Adding QML to a QGraphicsView based UI +If you have an existing QGraphicsView based UI you can create new items in QML, +and use QmlComponent to create QGraphicsObjects from the QML primitives. These +QGraphicsObjects can then be manually placed into your QGraphicsScene just like +any other. + +\section1 Using existing QGraphicsWidgets in QML +Another way of integrating with a QGraphicsView based UI is to expose your +existing QGraphicsWidgets to QML, and constructing your scene in QML. Note that +this approach will not work with QGraphicsItems which are not QGraphicsWidgets, +and that this approach allows you to integrate new items written in QML +without using the above method. + +As per the instructions in \l{Extending QML}, you can make custom C++ types +available in QML using a pair of macros. While this is normally only useful for +types that were designed for QML use, in conjunction with the +\l{GraphicsObjectContainer} element it works for QGraphicsWidgets which can be +controlled through properties. See the \l{GraphicsObjectContainer} +documentation for details about its use. This way you can write your UI using +QML, without having to rewrite any of your complex existing items. +*/ diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index 7b1ab44..26f73cb 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -65,7 +65,7 @@ QML provides direct access to the following concepts from Qt: \o Qt models - used directly in data binding (QAbstractItemModel and next generation QListModelInterface) \endlist -Qt knowledge is \e required for \l {Extending QML}. +Qt knowledge is \e required for \l {Extending QML}, and also for \l{Integrating QML with existing Qt UI code}. \section1 QML Items compared with QWidgets @@ -159,4 +159,5 @@ users of the compound item might wish to employ. For example, a spinbox might ne transition from an arbitrary Text item, or characters within a Text item, so your spinbox item would need to be sufficiently flexible to allow such animation. +\section1 QML Items Compared With QGraphicsWidgets */ |