4
votes

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");
1
You seem to register the type after you load the engine.cmannett85
^ That's likely the problem. Happens to me often. :DMitch
So, is there any solution? Or is this just a bug or smth.oksidez
You should the 2 lines, i.e. register the type before engine.load.sashoalm

1 Answers

8
votes

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