2
votes

I'm getting an error while trying to get Qt .qml environment working in CLion, cause I don't really want to use QtCreator:

QQmlApplicationEngine failed to load component
qrc:/main.qml:2:1: module "QtQuick.Window" is not installed
qrc:/main.qml:1:1: module "QtQuick" is not installed
qrc:/main.qml:2:1: module "QtQuick.Window" is not installed
qrc:/main.qml:1:1: module "QtQuick" is not installed

No idea what's going on, made a huge research and I haven't found anything. My QML file I'm trying to run is:

import QtQuick 2.12
import QtQuick.Window 2.12

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")
}

resources.qrc:

<RCC>
    <qresource>
        <file>main.qml</file>
    </qresource>
</RCC>

CMakeLists.txt: https://gist.github.com/zmatez/52d7a552d10d82beed8d86783b1322eb

CMake options:

-DCMAKE_PREFIX_PATH="E:/ProgramFiles/qt/5.15.2/mingw81_64/lib/cmake/Qt5"

main.cpp: https://gist.github.com/zmatez/52d7a552d10d82beed8d86783b1322eb

I was comparing it with auto-generated code with QtCreator, and my is almost identical as the creator's one. Also, QtWidgets application was working fine in CLion on my current configuration.

Thanks for any help

1
You probably have to define path to Qt, especially QML modules, QML2_IMPORT_PATH ot whatever. The question actually doen't relate to QML but mostly to CLion. I guess there are lots of tutorials across the Internet.folibis
Woah that worked! Added environment variable QML2_IMPORT_PATH as "qt\5.15.2\mingw81_64\qml" and now it starts! Thanks ;)) And no there are no tutorials about QML in Clion, at least I couldn't find any.matez
@folibis thanks for your comment. I am getting the same error but in different case. I deployed a qml application as an appimage it works fine in deployed pc. but when I moved this appimage to another pc, it gives on terminal this same error. What is the problem and how can I solve it ?Yunus Temurlenk

1 Answers

0
votes

I was having the same issue. Thanks to @folibis' comment above my problem was solved. As suggested by him, I just had to add an environment variable QML2_IMPORT_PATH and set its value to %QTDIR%\qml.

In my case it was not CLion. It was an existing project which was using Qt Widgets for UI. It was to be changed to use QML instead. It was giving me all sorts of troubles while identifying the QtQuick module. I tried many things but nothing worked, but this trick worked like a charm.