C

Non-API level differences between Qt Quick Ultralite and Qt Quick

Overview

See also the list of Known Issues or Limitations.

Dealing with image resources

All images need to be registered at build time, using the Qt Quick Ultralite resource system, to be converted to the Qt Quick Ultralite asset storage format. By default, images will be included in the binary itself. Loading images from external storage, as described in Resources from external storage, still requires them to be registered and converted at build time.

Image optimizations

On some platforms, if you use a transformation to rotate or scale an image, it might be beneficial to compile the image in a different format. To enable this optimization, set the ImageFiles.MCU.resourceOptimizeForRotation or ImageFiles.MCU.resourceOptimizeForScale QmlProjectProperty on the image resource. Example:

ImageFiles{
    files: ["images/my_image.png"]
    MCU.resourceOptimizeForRotation: true
    MCU.resourceOptimizeForScale: true
}

In applications, icon images usually have only a single color with alpha transparency. Qt Quick Ultralite detects such images and stores them in an optimized alpha map format. This works as long as the image has only one color. If the image has big transparent border, the image is automatically cropped.

Script expressions

Qt Quick Ultralite does not fully support the ECMAScript Language Specification and only a minimal subset of APIs is implemented. However, you can still use script expressions in the following cases:

  • In a body of property bindings. These script expressions describe relationships between QML object properties. When dependencies of a property change, the property is automatically updated too, according to the specified relationship.
  • In a body of Signal handlers. These script statements are automatically evaluated whenever a QML object emits an associated signal.
  • In a definition of custom methods. Script functions that are defined within a body of a QML object become methods of that object.

Qt Quick Ultralite does not support using standalone JavaScript resource (.js) files. As the script code is converted to C++ code when you define custom script methods, it is important to declare an argument type. If a method returns a value, then the return type needs to be declared within the method signature. Inside a function, it is possible to use var variables, but they always must be initialized for the type to be deduced:

function getColor(i : int, pressed: bool) : color {
    var isEven = i % 2 == 0
    if (pressed) {
        return "#AAFFAA"
    }
    else if (isEven) {
        return "#AACCAA"
    }
    return "#CCAACC"
}

Model-View-Delegate pattern

Models

In Qt Quick Ultralite, ListModels are read-only and there are restrictions on defining models in separate files. See Models and Views in Qt Quick Ultralite for details.

Role access

Unlike in Qt Quick, unqualified access to model's roles is allowed only when corresponding required property is declared in the delegate:

ListModel {
    id: model
    ListElement {
        cost: "2.45"
    }
}

ListView {
    model: model
    delegate: Text {
        required property string cost
        text: cost
    }
}

Delegates

Qt Quick Ultralite requires that the delegate is declared in the same file that it is used in.

To optimize run time memory footprint and to avoid dynamic allocations, only a certain number of delegates are created. The exact number of delegates is estimated during compile time and the estimation is based on a view container size and the delegate size.

The number of created delegates is higher than the number of visible delegates. For example, that enables a smooth scrolling effect. Once a delegate becomes invisible it can be reused and filled with data that corresponds to elements that soon becomes visible.

No white background

Qt Quick Ultralite does not draw the application on a white background. Applications must ensure they have no transparent regions to avoid rendering artifacts.

For example, the following draws a red rectangle on white background in Qt Quick:

Item {
    width: 200; height: 200
    Rectangle {
        width: 100; height: 100
        anchors.centerIn: parent
        color: "red"
    }
}

In Qt Quick Ultralite, the white areas in this example are not drawn to. That means the initial framebuffer data may be visible, and animations over the area will not properly clear old graphics.

The white background can be provided explicitly by using a white Rectangle as the root element:

Rectangle {
    Item {
        width: 200; height: 200
        Rectangle {
            width: 100; height: 100
            anchors.centerIn: parent
            color: "red"
        }
    }
}

Available under certain Qt licenses.
Find out more.