Qt QML Release Notes

Qt 5.0

The QtQml C++ module is new in Qt 5. It provides the QML engine and implements the QML language supporting infrastructure.

(Prior to Qt 5, this functionality was provided by the QtDeclarative module, which has now been replaced by the new QtQml and QtQuick C++ modules. See the Porting QML Applications to Qt 5 for more information.)

QML Engine

  • JavaScript engine has changed to V8.
  • Various parser and compiler optimizations have been implemented, as well as a new bindings optimizer.
  • New QQmlEngine::trimComponentCache() method safely discards unused data in the engine's component cache to free memory.

Component and Object Creation

  • QML objects can now be created asynchronously to improve application performance.
    • New QQmlIncubator and QQmlIncubationController C++ classes can be used to create objects asynchronously.
    • From QML code, this behavior can enabled by:
      • Calling the new Component Component::incubateObject method
      • Passing the Component.Asynchronous parameter to Qt.createComponent()
      • Loading a Loader object asynchronously using the asynchronous property
  • The component returned by Qt.createComponent() is no longer parented to the engine. Be sure to hold a reference, or provide a parent.

Type System

  • New var property type. This is a general-purpose property type which obsoletes the variant(obsolete) type. Properties of the var type may hold JavaScript references.
  • QML properties of type var and variant(obsolete) can now hold pixmaps. See Scarce Resources in JavaScript for more information.
  • Value type improvements:
    • QML now supports defining properties of value type basic types within QML documents. Supported types include QSizeF, QPointF and QRectF as size, point and rect respectively.
    • QColor is now a value type provided by the QtQuick module. The red, green, blue and alpha channels of a color property can be accessed via r, g, b and a properties.
    • Factory functions for various value types have been added to the Qt object exposed to QML. Some of those functions require the QtQuick module to be imported in order to return valid values. See the QtQuick 2.0 release notes for more information about these functions.
  • Support for sequence types QList<int>, QList<qreal>, QList<bool>, QList<QUrl>, QList<QString> and QStringList has been improved. QObjects can define Q_PROPERTYs of these types which can be accessed transparently from JavaScript.

Modules and Imports

  • Arbitrary functionality may be provided in a namespace through a singleton type. See qmlRegisterSingletonType() for more information.
  • JavaScript (.js) files may now import QML modules and other JavaScript files using the ".import" syntax.

Other

  • QQmlExpression can now be constructed directly (and more efficiently) from a QQmlScriptString.
  • The QML:Qt object now provides a QML:Qt::inputMethod property to access the active text input method for an application.