c++qtqmlqqmlcomponentqqmlapplicationengine

Error: QQmlApplicationEngine failed to load component


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

Solution

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