Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [solved]QQmlcomponent:component is not ready
Forum Update on Tuesday, May 27th 2025

[solved]QQmlcomponent:component is not ready

Scheduled Pinned Locked Moved Mobile and Embedded
9 Posts 2 Posters 36.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.
  • M Offline
    M Offline
    mahadin
    wrote on 22 May 2015, 19:43 last edited by mahadin
    #1

    i want to use QML object on C++ by these codes :
    // Using QQmlComponent

    QQmlEngine engine;
    QQmlComponent component(&engine,
    QUrl::fromLocalFile("MyItem.qml"));
    QObject *object = component.create();
    ...
    delete object;
    

    (from QT help )

    but get this mesage : QQmlcomponent:component is not ready
    :(

    when write a wrong address insted of MyItem.qml (use a address dos not exist) i get that too !
    i thing my Qml file is not accessable .
    please help me .

    P 1 Reply Last reply 23 May 2015, 05:54
    1
    • M mahadin
      22 May 2015, 19:43

      i want to use QML object on C++ by these codes :
      // Using QQmlComponent

      QQmlEngine engine;
      QQmlComponent component(&engine,
      QUrl::fromLocalFile("MyItem.qml"));
      QObject *object = component.create();
      ...
      delete object;
      

      (from QT help )

      but get this mesage : QQmlcomponent:component is not ready
      :(

      when write a wrong address insted of MyItem.qml (use a address dos not exist) i get that too !
      i thing my Qml file is not accessable .
      please help me .

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 23 May 2015, 05:54 last edited by
      #2

      Hi @mahadin and welcome,
      That error is thrown when the qml if not found as you said and also thrown even if there is an error in qml file. So check the accessibility of file first and for errors if any in the file.

      157

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mahadin
        wrote on 23 May 2015, 11:11 last edited by mahadin
        #3

        @p3c0
        Tanks
        I use a empty QML file like :

        import QtQuick 2.0

        Rectangle {
        width: 100
        height: 62
        }

        i have this problem with example code in QT help.
        how can I check the accessibility of QML file ?

        P 1 Reply Last reply 23 May 2015, 11:45
        1
        • M mahadin
          23 May 2015, 11:11

          @p3c0
          Tanks
          I use a empty QML file like :

          import QtQuick 2.0

          Rectangle {
          width: 100
          height: 62
          }

          i have this problem with example code in QT help.
          how can I check the accessibility of QML file ?

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 23 May 2015, 11:45 last edited by
          #4

          @mahadin Ok. The QML file looks good. Since you are using QUrl::fromLocalFile("MyItem.qml")) it means the file should present in the current working directory of the project. Either Check it manually by hand or use QFiles exist method to check the file.

          QFile file("MyItem.qml");
          file.exists();
          

          157

          1 Reply Last reply
          1
          • M Offline
            M Offline
            mahadin
            wrote on 23 May 2015, 15:22 last edited by
            #5

            I cheked it manually !
            it persent in direcrory that my .pro and main.cpp files is there . :(

            P 1 Reply Last reply 24 May 2015, 04:48
            1
            • M mahadin
              23 May 2015, 15:22

              I cheked it manually !
              it persent in direcrory that my .pro and main.cpp files is there . :(

              P Offline
              P Offline
              p3c0
              Moderators
              wrote on 24 May 2015, 04:48 last edited by
              #6

              @mahadin OK. What does file.exists() show ?

              157

              1 Reply Last reply
              1
              • M Offline
                M Offline
                mahadin
                wrote on 24 May 2015, 06:27 last edited by
                #7

                @p3c0
                i cheke it by these codes :

                QFile file("MyItem.qml");
                if (file.exists())msg.setText("exist");
                    else msg.setText("False");
                msg.exec();
                

                it return False ! :(
                ََ@p3c0 Tanks 4 your asnwers ! :)

                P 1 Reply Last reply 24 May 2015, 06:41
                1
                • M mahadin
                  24 May 2015, 06:27

                  @p3c0
                  i cheke it by these codes :

                  QFile file("MyItem.qml");
                  if (file.exists())msg.setText("exist");
                      else msg.setText("False");
                  msg.exec();
                  

                  it return False ! :(
                  ََ@p3c0 Tanks 4 your asnwers ! :)

                  P Offline
                  P Offline
                  p3c0
                  Moderators
                  wrote on 24 May 2015, 06:41 last edited by
                  #8

                  @mahadin Hmm, I guess the problem must be that the qml file is not present in the compiled executable's current working directory. Try giving a complete path of qml file instead.
                  Or you can add it in your qrc file and load it from there as follows:

                  QQmlComponent component(&engine,QUrl(QStringLiteral("qrc:/MyItem.qml")))
                  

                  157

                  1 Reply Last reply
                  3
                  • M Offline
                    M Offline
                    mahadin
                    wrote on 24 May 2015, 10:52 last edited by
                    #9

                    @p3c0
                    so taaaaaaaaaaanks :)
                    my problem solved ... :D

                    ممنون . خدا خیرتان دهد !

                    1 Reply Last reply
                    0

                    1/9

                    22 May 2015, 19:43

                    • Login

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