1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the documentation of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:FDL$
10 ** GNU Free Documentation License
11 ** Alternatively, this file may be used under the terms of the GNU Free
12 ** Documentation License version 1.3 as published by the Free Software
13 ** Foundation and appearing in the file included in the packaging of
17 ** Alternatively, this file may be used in accordance with the terms
18 ** and conditions contained in a signed written agreement between you
26 ****************************************************************************/
29 \title What's New in Qt Quick 2
30 \page qtquick2-whatsnew.html
31 \inqmlmodule QtQuick 2
33 \section1 Qt 5.0.0 includes QtQuick 2.0
35 QtQuick 2.0 is a major update.
37 \section2 SceneGraph renderer
39 QtQuick 2 is based on an OpenGL scenegraph. The following
40 classes replace their equivalents in QtQuick 1:
49 \section2 QML Engine/Language Improvements
51 JS engine changed to V8. For most QML users this should not make a visible difference beyond performance improvements, however a lot of undefined behavior semantics may have changed as well. As always, it is recommended not to rely on undefined behavior.
53 Parser and compiler optimizations.
55 New binding optimizer.
57 ValueType improvements:
58 - QColor is now a value type. The red, green, blue and alpha channels can be accessed via "r", "g", "b" and "a" properties
59 - Improved support for QVector4D, now constructible in QML via Qt.vector4d()
61 Arbitrary functionality may be provided in a namespace through a Module API. See \l{qmlRegisterModuleApi()} for more information.
63 JavaScript (.js) files may now import QML modules and other JavaScript files. See \l{Importing One JavaScript File From Another} for more information.
65 A new property type "var" has been added which obsoletes the old "variant" property type.
66 Properties of the "var" type may hold JavaScript references. See \l{QML Basic Types} for more information.
68 QML properties of type \c var and \c variant can now hold pixmaps. See \l{Scarce Resources in JavaScript} for more information
70 QDeclarativeExpression can now be directly (and more efficiently) constructed from a
71 QDeclarativeScriptString.
73 Support for certain sequence types (QList<int>, QList<qreal>, QList<bool>, QList<QUrl>, QList<QString> and QStringList) has been improved.
74 QObjects can define Q_PROPERTYs of these types which can be accessed transparently from JavaScript. See the section on
75 sequences in \l{Extending QML Functionalities using C++} for more information.
79 The new \l Canvas item provides a HTML5 canvas like API, with some enhancements:
80 1) Supports 2 render targets: Canvas.Image and Canvas.FramebufferObject
81 2) Supports background thread rendering
82 3) Supports tiled canvas rendering
84 The Canvas item supports most of the HTML5 context2d APIs, the API details please look at the canvas item documentation.
87 \section2 Particle System
89 The \l{QtQuick.Particles 2}{QtQuick.Particles} module contains elements that can be composed to form 2D particle system.
92 \section2 Element API/Behavior Changes
94 New \l SpriteImage element renders animated sprites and can transition between animations.
95 It uses the \l Sprite element to represent each animation.
97 MouseArea can now propagate clicked, doubleClicked and pressAndHold differently to pressed.
98 These can now be propagated to the highest-stacking-order enabled MouseArea which has a handler for them.
99 You can still ignore these events in the handler to let them pass through.
100 This behavior is triggered with the new property propagateComposedEvents.
102 The Binding element can now be used as a value source, and will also restore any previously
103 set binding when its \i when clause becomes false.
105 Flickable: added dragging, draggingHorizontally and draggingVerically properties.
106 Added topMargin, bottomMargin, leftMargin, rightMargin, xOrigin, yOrigin properties.
108 Image has two new properties: horizontalAlignment and verticalAlignment. It also has a new value for
109 fillMode (Image.Pad) that does not transform the image.
111 Grid now has rowSpacing and columnSpacing properties.
113 Positioners now have attached properties that can be used to determine a subitem's location within a
114 container such as Column or Row: Positioner.index, Positioner.isFirstItem, Positioner.isLastItem.
117 - "active" property added to Loader, to allow delaying instantiation of a Loader element's item property
118 - "setSource(JSObject)" method added to Loader to allow initial property values to be specified (similar to Component.createObject())
119 - now only emits the \c sourceChanged signal when the source is changed and the
120 \c sourceComponentChanged signal when the sourceComponent is changed. It used to emit both signals when one of the properties was changed.
123 - a \c onLineLaidOut handler is called for every line during the layout process. This gives the opportunity to position and resize a line as it is being laid out.
124 - a \c doLayout method was added to trigger the layout from Javascript.
125 - now automatically switch to StyledText instead of RichText if textFormat is set to AutoText.
128 - the default value of the textFormat property is now PlainText instead of AutoText.
130 TextInput has new wrapMode and verticalAlignment properties, and the positionAt function now takes
133 PathView now has a \c currentItem property
135 ListView and GridView:
136 - now have headerItem and footerItem properties (the instantiated header and footer items).
137 - In RightToLeft layout the preferredHighlightBegin/End are now also reversed.
139 ListView section.labelPositioning property added to allow keeping the current section label
140 at the start and/or next section label at the end of the view.
142 A new property type ("var") has been introduced which obsoletes "variant" properties in QML.
143 Properties of this type are equivalent to regular JavaScript variables. See the documentation
144 on \l{QML Basic Types} for more information about "var" properties.
146 New elements have been added for contructing paths: PathArc, PathCurve, PathSvg.
148 \section2 QtQuick 1 is now a separate library and module
150 Writing C++ applications using QtQuick 1 specific API, i.e. QDeclarativeView or QDeclarativeItem
151 requires adding the "qtquick1" module to the .pro file, e.g. QT += declarative qtquick1
153 QDeclarativeView and QDeclarativeItem headers are now in the QtQuick 1 module, i.e.
154 #include <QtQuick1/QDeclarativeView>
155 #include <QtQuick1/QDeclarativeItem>
157 "import QtQuick 1.0" loads the module dynamically. To deploy QtQuick 1 applications
158 the library (lib/libQtQuick1*) and plugin (imports/QtQuick/) must be installed.
160 \sa {What's New in Qt Quick 1}{What's New in Qt Quick 1}