QML runtime enivronment not found

234 views Asked by At

There are a few questions similar to this on Stackoverflow but none of them really answers clearly. I have QT version 5 (64-bit windows). I have just started learning QML but don't know how to run it. The website says that a QML runtime environment should be provided and it is installed with the QT itself. But there is no QML runtime environment on my computer. How to provide this environment manually?

1

There are 1 answers

0
Ceopee On

As the Qt document says,

Applications that use QML must invoke the QML runtime to run QML documents. You can do this by creating a QQuickView or a QQmlEngine. In addition, the Declarative UI package includes the qmlscene tool, which loads .qml files. This tool is useful for developing and testing QML code without having to write a C++ application to load the QML runtime.

You can only write a simple qml file and run it with qmlscene.exe.

hello.qml

import QtQuick 2.0

Rectangle {
    width: 640
    height: 480
    color: "lightgray"

    Text {
        anchors.centerIn: parent
        text: "Hello, QML!"
    }
}

From cmd you can execute %qt_dir%/%qt_version%/%platform%/bin/qmlscene.exe For my own environment C:\Qt\5.12.8\msvc2017_64\bin\qmlscene.exe hello.qml resulted like

enter image description here

cheers