Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QQmlApplicationEngine failed to load component
QtWS25 Last Chance

QQmlApplicationEngine failed to load component

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 3.4k Views
  • 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.
  • A Offline
    A Offline
    Aminmlp
    wrote on 20 Jun 2020, 12:23 last edited by
    #1

    I use Qt in VS 2017 widows 10. here is code

    cfae1f41-d6fc-4abb-b953-a6bb2788995e-image.png

    and here is the error

    46504602-73e5-41eb-8bae-8ef50f6f41f6-image.png

    what is the problem?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 20 Jun 2020, 14:09 last edited by
      #2

      The code you're showing does not contain any errors.

      Loading of main.qml fails at runtime, which suggests that:

      • QRC file was not compiled
      • QRC file was not included in the compiled binary
      • main.qml is not in the QRC file

      (Z(:^

      A 1 Reply Last reply 21 Jun 2020, 04:14
      1
      • S sierdzio
        20 Jun 2020, 14:09

        The code you're showing does not contain any errors.

        Loading of main.qml fails at runtime, which suggests that:

        • QRC file was not compiled
        • QRC file was not included in the compiled binary
        • main.qml is not in the QRC file
        A Offline
        A Offline
        Aminmlp
        wrote on 21 Jun 2020, 04:14 last edited by
        #3

        @sierdzio can you explain more, please?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 21 Jun 2020, 05:44 last edited by sierdzio
          #4

          But what should I explain?

          I see you are using Visual Studio, so your setup is probably unusual. I do not know what build system you are using (qmake, cmake, something else?). I do not know if you are using QRC file at all (are you?). I have not seen the code of your QRC file, nor your build system files (*.pro or CMakeLists.txt). I can't guess all that.

          (Z(:^

          A 1 Reply Last reply 21 Jun 2020, 07:07
          1
          • S sierdzio
            21 Jun 2020, 05:44

            But what should I explain?

            I see you are using Visual Studio, so your setup is probably unusual. I do not know what build system you are using (qmake, cmake, something else?). I do not know if you are using QRC file at all (are you?). I have not seen the code of your QRC file, nor your build system files (*.pro or CMakeLists.txt). I can't guess all that.

            A Offline
            A Offline
            Aminmlp
            wrote on 21 Jun 2020, 07:07 last edited by
            #5

            @sierdzio I add .qrc and .qml file to my project. but I think this address "qrc:/main.qml" can not be found, why?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 22 Jun 2020, 05:03 last edited by
              #6

              Because it's either wrong (do you have main.qml file? Is it added to QRC? Is the path and QRC syntax correct?) or the resource file is not properly added / linked into the binary.

              Since you have still not shown any code, I can only keep guessing.

              (Z(:^

              A 1 Reply Last reply 22 Jun 2020, 05:11
              0
              • S sierdzio
                22 Jun 2020, 05:03

                Because it's either wrong (do you have main.qml file? Is it added to QRC? Is the path and QRC syntax correct?) or the resource file is not properly added / linked into the binary.

                Since you have still not shown any code, I can only keep guessing.

                A Offline
                A Offline
                Aminmlp
                wrote on 22 Jun 2020, 05:11 last edited by
                #7

                @sierdzio here is my resource

                0fc8f43a-36fa-4d64-8dc9-098a69e4ff07-image.png

                J 1 Reply Last reply 22 Jun 2020, 05:16
                0
                • S Offline
                  S Offline
                  sierdzio
                  Moderators
                  wrote on 22 Jun 2020, 05:16 last edited by
                  #8

                  See the "Resource URL" field: this is what you need to paste into your source code.

                  So it's:

                  engine.load(QUrl("qrc:/qrc/mian.qml"));
                  

                  Notice it's mian and and not main - you've made a typo.

                  BTW. In the future, please paste code, not pictures. This way I can copy-paste and tweak your stuff to help you, instead of typing everything myself.

                  (Z(:^

                  1 Reply Last reply
                  2
                  • A Aminmlp
                    22 Jun 2020, 05:11

                    @sierdzio here is my resource

                    0fc8f43a-36fa-4d64-8dc9-098a69e4ff07-image.png

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 22 Jun 2020, 05:16 last edited by
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Aminmlp
                      wrote on 22 Jun 2020, 05:54 last edited by
                      #10

                      @sierdzio said in QQmlApplicationEngine failed to load component:

                      qrc:/qrc/mian.qml

                      problem solved, thanks

                      1 Reply Last reply
                      0

                      1/10

                      20 Jun 2020, 12:23

                      • Login

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