Home > Back-end >  QML import version 2.0 vs minor versions e.g. 2.12 2.15
QML import version 2.0 vs minor versions e.g. 2.12 2.15

Time:10-08

I'm always confused about which import version should I use.

For example, I installed Qt version 5.12 and do import QtQuick 2.0. Does this mean I get the latest feature that comes with Qt 5.12? Or should I use import QtQuick 2.12 to get the latest features?

CodePudding user response:

Yes, for the most up to date features, you should import the highest version of the given libraries that you have. For example, here is a stand alone test:

import QtQuick 2.0
import QtQml 2.0
import QtQuick.Window 2.0

Window {
    id: root
    width: 640
    height: 480
    visible: true

    Binding {
        delayed: true
    }
}

Running this example will throw the following error and quit immediately: qrc:/main.qml:14 "Binding.delayed" is not available in QtQml 2.0.

Per the version note in the documentation ("This property was introduced in Qt 5.8"), changing the QtQml import to 2.8 or greater will allow this to run properly.

  • Related