【发布时间】:2021-03-16 22:17:22
【问题描述】:
我在尝试让 Qt .qml 环境在 CLion 中工作时遇到错误,因为我真的不想使用 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
不知道发生了什么,进行了大量研究,但我没有发现任何东西。 我尝试运行的 QML 文件是:
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 选项:
-DCMAKE_PREFIX_PATH="E:/ProgramFiles/qt/5.15.2/mingw81_64/lib/cmake/Qt5"
main.cpp:https://gist.github.com/zmatez/52d7a552d10d82beed8d86783b1322eb
我将它与使用 QtCreator 自动生成的代码进行比较,我的代码几乎与创建者的代码相同。 此外,在我当前的配置下,QtWidgets 应用程序在 CLion 中运行良好。
感谢您的帮助
【问题讨论】:
-
您可能必须定义 Qt 的路径,尤其是 QML 模块,
QML2_IMPORT_PATH等等。这个问题实际上与 QML 无关,但主要与 CLion 有关。我猜网上有很多教程。 -
哇,成功了!将环境变量 QML2_IMPORT_PATH 添加为“qt\5.15.2\mingw81_64\qml”,现在它开始了!谢谢 ;)) 没有关于 Clion 中 QML 的教程,至少我找不到。
-
@folibis 感谢您的评论。我得到了同样的错误,但在不同的情况下。我将 qml 应用程序部署为 appimage 它在部署的 pc 中运行良好。但是当我将这个 appimage 移到另一台电脑上时,它在终端上给出了同样的错误。是什么问题,我该如何解决?