Error: QQmlApplicationEngine failed to load component

oksidez picture oksidez · Feb 6, 2015 · Viewed 15k times · Source

I try to register a type, but I'm getting this error:

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

Answer

cmannett85 picture cmannett85 · Feb 6, 2015

Instead of this:

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

Do this:

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