Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML import error
Forum Updated to NodeBB v4.3 + New Features

QML import error

Scheduled Pinned Locked Moved QML and Qt Quick
qmlc++androidqtquick2
1 Posts 1 Posters 773 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dmitriy_RUS
    wrote on last edited by
    #1

    I wanted to create a new QML type from C++ but I encountered a problem in the process, which I couldn't resolve. I have a class in C++ - "Mytype" - which has been registered with the QML Type System via qmlregistertype function.

    So far so good. The class was correctly registered and the application run fine on desktop environments, everything worked fine. However, when I built and deployed the application to an Android device, I received the following error:

    Warning: QML import could not be resolved in any of the import paths: mytype

    What does this error talk about? What could be the reason for this error? How can I fix it? Please, help me. Here follows a simplified code example:
    c++:

        #include <QApplication>
        #include <QQmlApplicationEngine>
        #include "mytype.h"
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        qmlRegisterType<Mytype>("mytype", 1, 0, "Mytype");
    
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        return app.exec();
    }
    

    qml:

    import mytype 1.0;
    ...
    Mytype {
        id: my_type;
        ...
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved