Results 1 to 5 of 5

Thread: QML import error

  1. #1
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default QML import error

    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++:
    Qt Code:
    1. #include <QApplication>
    2. #include <QQmlApplicationEngine>
    3. #include "mytype.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. qmlRegisterType<Mytype>("mytype", 1, 0, "Mytype");
    10.  
    11. QQmlApplicationEngine engine;
    12. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    13.  
    14. return app.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    qml:
    Qt Code:
    1. import mytype 1.0;
    2. ...
    3. Mytype {
    4. id: my_type;
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Dmitriy_RUS; 29th May 2015 at 15:45.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QML import error

    The type you are registering is called "Mytest", the type you are using is "Mytype"

    Cheers,
    _

  3. #3
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QML import error

    Quote Originally Posted by Dmitriy_RUS View Post
    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:



    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:

    Qt Code:
    1. #include <QApplication>
    2. #include <QQmlApplicationEngine>
    3. #include "mytype.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. qmlRegisterType<Mytype>("mytype", 1, 0, "Mytype");
    10.  
    11. QQmlApplicationEngine engine;
    12. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    13.  
    14. return app.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. import mytype 1.0;
    2. ...
    3. Mytype {
    4. id: my_type;
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 
    Help me, please!

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QML import error

    As I said before: you have two different character sequences.
    The type you are registring is not the one you are using.

    But maybe I am replying to a bot.

    Cheers,
    _

  5. #5
    Join Date
    May 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QML import error

    Please, look once again at the description of a problem. I don't see a mistake there.

Similar Threads

  1. QML's import does not work
    By MarkoSan in forum Qt Programming
    Replies: 9
    Last Post: 8th September 2014, 13:33
  2. Cannot import my graph
    By Stanfillirenfro in forum Qt Programming
    Replies: 2
    Last Post: 26th April 2014, 21:41
  3. Replies: 3
    Last Post: 6th October 2011, 11:14
  4. How to import qss into another qss file
    By bedbuffer in forum Newbie
    Replies: 1
    Last Post: 4th April 2011, 11:22
  5. import pdf in a QGraphicsView
    By tilsitt in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2011, 16:18

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.