Error: QQmlApplicationEngine failed to load component

Error: QQmlApplicationEngine failed to load component

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

QQmlApplicationEngine 加载组件失败
qrc:/main.qml:5 模块 "Komut" 未安装 

这是我正在使用的代码:

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