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. QQmlApplicationEngine failed to load component
Forum Updated to NodeBB v4.3 + New Features

QQmlApplicationEngine failed to load component

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 2 Posters 6.4k Views 2 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.
  • small_birdS Offline
    small_birdS Offline
    small_bird
    wrote on last edited by small_bird
    #1

    Hello, everyone. I came across one problem:

    import QtQuick 2.4
    import QtQuick.Controls 1.4
    import QtQuick.Window 2.2
    import NewClass 1.0
    

    The output says:

    Starting C:\Users\DELL\Desktop\gicap-zhouyang20180321\debug\gicap-zhouyang20180321.exe...
    QML debugging is enabled. Only use this in a safe environment.
    QQmlApplicationEngine failed to load component
    qrc:/SelectMethodFileWindow.qml:6 module "NewClass" is not installed
    

    This is my main function:

    int main(int argc, char *argv[])
    {
        QApplication app(argc,argv);
    
        DataSource* dataSource=new DataSource(NULL);
    
        qmlRegisterType<NewClass>("NewClass",1,0,"newClass");
    
        QQmlApplicationEngine engine;
    
        engine.load(QUrl(QStringLiteral("qrc:/SelectMethodFileWindow.qml")));
        engine.rootContext()->setContextProperty("dataSource", dataSource);
    
        if (engine.rootObjects().isEmpty())
        {
            return -1;
        }
    
        return app.exec();
    }
    
    

    How to solve that? Could anyone help me?Thanks in advance!

    A 1 Reply Last reply
    0
    • small_birdS small_bird

      Hello, everyone. I came across one problem:

      import QtQuick 2.4
      import QtQuick.Controls 1.4
      import QtQuick.Window 2.2
      import NewClass 1.0
      

      The output says:

      Starting C:\Users\DELL\Desktop\gicap-zhouyang20180321\debug\gicap-zhouyang20180321.exe...
      QML debugging is enabled. Only use this in a safe environment.
      QQmlApplicationEngine failed to load component
      qrc:/SelectMethodFileWindow.qml:6 module "NewClass" is not installed
      

      This is my main function:

      int main(int argc, char *argv[])
      {
          QApplication app(argc,argv);
      
          DataSource* dataSource=new DataSource(NULL);
      
          qmlRegisterType<NewClass>("NewClass",1,0,"newClass");
      
          QQmlApplicationEngine engine;
      
          engine.load(QUrl(QStringLiteral("qrc:/SelectMethodFileWindow.qml")));
          engine.rootContext()->setContextProperty("dataSource", dataSource);
      
          if (engine.rootObjects().isEmpty())
          {
              return -1;
          }
      
          return app.exec();
      }
      
      

      How to solve that? Could anyone help me?Thanks in advance!

      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @small_bird This page should help you. It explains all of the QML import stuff.

      http://doc.qt.io/qt-5/qtqml-syntax-imports.html

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      small_birdS 1 Reply Last reply
      0
      • A ambershark

        @small_bird This page should help you. It explains all of the QML import stuff.

        http://doc.qt.io/qt-5/qtqml-syntax-imports.html

        small_birdS Offline
        small_birdS Offline
        small_bird
        wrote on last edited by
        #3

        @ambershark Thanks a lot, however, my problem is not within the scope.

        A 3 Replies Last reply
        0
        • small_birdS small_bird

          @ambershark Thanks a lot, however, my problem is not within the scope.

          A Offline
          A Offline
          ambershark
          wrote on last edited by
          #4

          @small_bird It looks like it is to me. I just briefly browsed that link I sent you and found a potential problem right away.

          You never check your return code from qmlRegisterType.. You may not be successfully registering your type which would account for that error.

          From the docs http://doc.qt.io/qt-5/qqmlengine.html#qmlRegisterType that I linked to from the link I just sent before.

          I'm betting that registration is returning a -1 indicating a failure to register.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          1 Reply Last reply
          0
          • small_birdS small_bird

            @ambershark Thanks a lot, however, my problem is not within the scope.

            A Offline
            A Offline
            ambershark
            wrote on last edited by
            #5

            @small_bird Also I can't see the top of your main but are you including QDeclarativeComponent? If so try replacing that with a #include <QQuickItem> and see if that works.

            My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

            1 Reply Last reply
            0
            • small_birdS small_bird

              @ambershark Thanks a lot, however, my problem is not within the scope.

              A Offline
              A Offline
              ambershark
              wrote on last edited by
              #6

              @small_bird One last idea before I head to bed... Try cleaning and rerunning your build. I've had weirdness like this happen with a dirty build before.

              Make sure to rerun cmake or qmake or whatever build you use to refresh your makefiles and then build again and test it.

              Hope one of those ideas work, I'm off to bed, good luck! :)

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              small_birdS 2 Replies Last reply
              2
              • A ambershark

                @small_bird One last idea before I head to bed... Try cleaning and rerunning your build. I've had weirdness like this happen with a dirty build before.

                Make sure to rerun cmake or qmake or whatever build you use to refresh your makefiles and then build again and test it.

                Hope one of those ideas work, I'm off to bed, good luck! :)

                small_birdS Offline
                small_birdS Offline
                small_bird
                wrote on last edited by
                #7

                @ambershark En, thanks a lot, good night!

                1 Reply Last reply
                0
                • A ambershark

                  @small_bird One last idea before I head to bed... Try cleaning and rerunning your build. I've had weirdness like this happen with a dirty build before.

                  Make sure to rerun cmake or qmake or whatever build you use to refresh your makefiles and then build again and test it.

                  Hope one of those ideas work, I'm off to bed, good luck! :)

                  small_birdS Offline
                  small_birdS Offline
                  small_bird
                  wrote on last edited by
                  #8

                  @ambershark Yes, the return value is -1.

                  A 1 Reply Last reply
                  0
                  • small_birdS small_bird

                    @ambershark Yes, the return value is -1.

                    A Offline
                    A Offline
                    ambershark
                    wrote on last edited by
                    #9

                    @small_bird Yea so if it's -1 that means your registration of that type is failing. Now you just have to figure out why your NewClass type is not registering properly and the QML side should start working.

                    I don't see anything obvious from the code you posted, but at least you know where the problem is now. :)

                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                    small_birdS 1 Reply Last reply
                    0
                    • A ambershark

                      @small_bird Yea so if it's -1 that means your registration of that type is failing. Now you just have to figure out why your NewClass type is not registering properly and the QML side should start working.

                      I don't see anything obvious from the code you posted, but at least you know where the problem is now. :)

                      small_birdS Offline
                      small_birdS Offline
                      small_bird
                      wrote on last edited by
                      #10

                      @ambershark En, thanks a lot! The problem has been solved: the letter "newCLass" should be "NewCLass". Thanks very much.

                      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