QML1-vs-QML2
QtQuick 1 vs QtQuick
work in progress
The idea of this wiki page is to have a “some how” porting guide for customers, having a Qt 4.8/QtQuick 1 application, to get a Qt5/QtQuick 2 application. The focus is on the QML part, not the c++ part. What are new elements, which elements are deprecated, what needs to be changed.
ideas from Girish:
- The change in javascript engines.
- What’s changed in the js syntax in QML2 (if any)
- C++ api changes – like how does we create items these days? How is it different from QML1
- Dependency on GLES2 unlike QML1
For porting an existing QtQuick 1 application to QtQuick 2 and make use of new features of QtQuick 2, there are some changes in the QML files necessary, which are listed below.
QtQuick 1 | QtQuick 2 |
---|---|
import QtQuick 1.0 | import QtQuick 2.0 |
import Qt.labs.particles 1.0 | import QtQuick.Particles 2.0 |
import Qt.labs.shaders 1.0 | import QtQuick 2.0 |
import QtQuick 1.0 | import QtQuick.XmlListModel 2.0 |
import QtMobility.location 1.2 | import QtLocation 5.0 |
import QtMobility.sensors 1.3 | import QtSensors 5.0 |
import QtMobility.systeminfo 1.1 | import QtSystemInfo 5.0 |
import QtMultimediaKit 1.1 | import QtMultimedia 5.0 |
./qmlviewer | ./qmlscene |
For a more detailed list of changes in QtQuick 2, see What’s New in Qt Quick 2 [qt.io]
See also the Qt documentation’s porting guide [qt.io]
A description, how to port your Qt 4.x application to Qt 5 is here [wiki.qt.io]
New QML elements in QtQuick2:
- a new particle system: http://doc.qt.io/qt-5.0/qmlmodule-qtquick-particles2-qtquick-particles-2.html
- new Shader effects system: http://doc.qt.io/qt-5.0/qtquick-effects-shaders.html
- Canvas [qt.io] – Provides a 2D canvas element
- CanvasGradient [qt.io] – Context2D opaque CanvasGradient interface
- Context2D [qt.io] – The Context2D API allows you to draw 2d graphic shapes on the Canvas item.
- TextMetrics [qt.io] – Context2D TextMetrics interface
- MultiPointTouchArea [qt.io] – Enables handling of multiple touch points
- TouchPoint [qt.io] – The TouchPoint element describes a touch point in a MultiPointTouchArea
- PathAnimation [qt.io] – Animates position along a path
- PathInterpolator [qt.io] – Allows manual animation along a path
- AnimationController [qt.io] – Allows manual control of animation progress
- PathArc [qt.io] – Defines an arc in a Path
- PathCurve [qt.io] – Defines a point on a Catmull-Rom curve in a Path
- PathSvg [qt.io] – Defines a sub-path specified as a SVG path data string in a Path
- Accessible [qt.io] – Attached property to make components accessible
- AnimatedSprite [qt.io] – The AnimatedSprite element draws a sprite animation
- Sprite [qt.io] – The Sprite element represents a sprite animation
- SpriteSequence [qt.io] – The SpriteSequence element draws a sprite animation
- DragEvent [qt.io] – The DragEvent object provides information about a drag event.
- DropArea [qt.io] – The DropArea item provides drag and drop handling.
QML element not available in QtQuick 2 anymore:
- LayoutItem [qt.io] – Allows declarative UI elements inside Qt’s Graphics View layouts