c++ - 错误 : QQmlApplicationEngine failed to load component

标签 c++ qt qml qqmlcomponent qqmlapplicationengine

我尝试注册一个类型,但出现此错误:

QQmlApplicationEngine failed to load component
qrc:/main.qml:5 module "Komut" is not installed

This is the code I'm using:

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
qmlRegisterType<Execom>("Komut",1,0,"Execom");

最佳答案

取而代之的是:

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
qmlRegisterType<Execom>("Komut",1,0,"Execom");

这样做:

qmlRegisterType<Execom>("Komut",1,0,"Execom");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

关于c++ - 错误 : QQmlApplicationEngine failed to load component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28369294/

相关文章:

c# - 从 C# 调用 C++ DLL 函数时崩溃

c++ - Visual Studio 2017 在 extern "C"中使用模板时出现不正确的错误

c++ - Qt:QPlastiqueStyle 未命名类型

c++ - 使用图像的形状在 qt 中创建一个窗口

qt - 使用 QML 播放动画 SVG

qt - qt qml 和 qt Quick 的区别

scope - QML 范围 : property binding in child object failing

c++ - QGraphicsPixmapItem如何设置鼠标碰撞框? [QT/C++]

c++ - 在模板类构造函数中创建一个计数器

Qt QMdiArea 背景上的图像