C

QML API changes

Removed QML types and features

Here is a list of removed QML types and modules

QML API or moduleAlternative
Qt Charts moduleThere is no replacement, but a workaround with static images can be used. The thermostat demo.
Javascript Date APICurrently there is no replacement.
toFixedInt()toFixed()
toExponentialAuto()toExponential()

Moved QulPerf

QulPerf has been moved to the Qt Quick Ultralite Extras QML module. You should now import the Qt Quick Ultralite Extras QML module to use it.

For example, if you have code like

import QtQuick 2.15
Row {
    id: root
    visible: QulPerf.enabled

    PerformanceMetricItem {
        label: "FPS:"
        value: QulPerf.fps.toFixed(2)
    }
}

you can rewrite it as

import QtQuick 2.15
import QtQuickUltralite.Extras 2.0
Row {
    id: root
    visible: QulPerf.enabled

    PerformanceMetricItem {
        label: "FPS:"
        value: QulPerf.fps.toFixed(2)
    }
}

JavaScript expressions in a ListElement

JavaScript expressions can no longer be bound with a property value in a ListElement. The ListElement now limits the possible values to constants and qsTr() calls only. This changes is compatible with Qt.

For example, if you have code like

ListModel {
    id: fruitModel

    ListElement {
        name: "Apple"
        cost: { 5 + 10 }
    }
    ListElement {
        name: "Orange"
        cost: 3.25
    }
}

you can rewrite it as

ListModel {
    id: fruitModel

    ListElement {
        name: "Apple"
        cost: 15
    }
    ListElement {
        name: "Orange"
        cost: 3.25
    }
}

Item margins in AnchorChanges

AnchorChanges can no longer be used to modify the margins of an item. Use PropertyChanges instead.

For example, if you have code like

AnchorChanges {
    target: myRect
    anchors {
        top: anchorRectEnd.top
        bottom: anchorRectEnd.bottom
        left: anchorRectEnd.left
        right: anchorRectEnd.right
        topMargin: 20
        bottomMargin: 20
        leftMargin: 20
        rightMargin: 20
    }
}

you can rewrite it as

AnchorChanges {
    target: myRectanchors {
        top: anchorRectEnd.top
        bottom: anchorRectEnd.bottom
        left: anchorRectEnd.left
        right: anchorRectEnd.right
    }
}
PropertyChanges {
    target: myRect
    anchors {
        topMargin: 20
        bottomMargin: 20
        leftMargin: 20
        rightMargin: 20
    }
}

Text alignment

The enumeration values for horizontalAlignment and verticalAlignment properties have been unified for both Text and StaticText items. These types now use the Text.horizontalAlignment and Text.verticalAlignment values instead.

For example, if you have code like

StaticText {
    horizontalAlignment: StaticText.AlignRight
    verticalAlignment: StaticText.AlignVCenter
    text: "right aligned"
}

you can rewrite it as

StaticText {
    horizontalAlignment: Text.AlignRight
    verticalAlignment: Text.AlignVCenter
    text: "right aligned"
}

Limit unicode coverage Font

The font.unicodeCoverage property is supported in Qt.font() context only.

For example, if you have code like

Text {
    font.unicodeCoverage: [Font.UnicodeBlock_BasicLatin]
}

you can rewrite it as

Text {
    font: Qt.font({ unicodeCoverage: [Font.UnicodeBlock_BasicLatin]})
}

Available under certain Qt licenses.
Find out more.