错误:QQmlApplicationEngine无法加载组件

时间:2015-02-06 15:36:38

标签: c++ qt qml qqmlcomponent qqmlapplicationengine

我尝试注册一个类型,但是我收到了这个错误:

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

这是我正在使用的代码:

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

1 个答案:

答案 0 :(得分:3)

而不是:

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")));