我尝试注册一个类型,但是我收到了这个错误:
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");
答案 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")));