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. [SOLVED] QML on Windows: MyComponent is not a type

[SOLVED] QML on Windows: MyComponent is not a type

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 14.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.
  • B Offline
    B Offline
    blueblood
    wrote on 25 Aug 2014, 06:37 last edited by
    #1

    Hello,

    I have a problem with QML on Windows that doesn't seem to be very common on the net. I'm using Qt 5.3.1.

    I'm using QtCreator for the project. I added some qml components through the IDE interface, and inspecting them on disk reveals that main.qml and all the other components it's loading are in the same directory.

    here's the problem:

    @engine.load(QUrl(QStringLiteral("qrc:///main.qml")));@

    QmlApplicationEngine failed to load component
    qrc:///main.qml:14 PlaylistOpenDialog is not a type

    PlaylistOpenDialog.qml is in the same directory as main.qml. QtCreator is actually auto-completing it's name when I type it.

    Now, there's that closed bug https://bugreports.qt-project.org/browse/QTBUG-26417 , which recommends that I use absolute paths. Ignoring the deployment issue of using an absolute path, I do not know how to specify it on Windows. If I write "qml:/D:\MyProject" for example, it doesn't work. It may be that Qt is mistaking D: as another protocol or something. Removing the colon doesn't help, either. I also tried replacing backward slashes with forward ones.

    So please, help me load this thing, using relative paths if possible.

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 25 Aug 2014, 07:41 last edited by
      #2

      I suspect Qt is having a trouble with the resource file. Try adding something like this to your main.qml:
      @
      import ":/"
      @

      (Z(:^

      1 Reply Last reply
      2
      • B Offline
        B Offline
        blueblood
        wrote on 25 Aug 2014, 07:50 last edited by
        #3

        Thanks for your reply.

        I did that, and I get:

        qrc:///main.qml:3 ":/": no such directory

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 25 Aug 2014, 07:54 last edited by
          #4

          Try different combinations, like "qrc:/", "qrc:///", etc.

          Are those component files also in the same prefix (folder) in the QRC file? Maybe you have moved them somewhere else?

          (Z(:^

          1 Reply Last reply
          1
          • B Offline
            B Offline
            blueblood
            wrote on 25 Aug 2014, 08:05 last edited by
            #5

            I tried "qrc:/" with both the import suggested and without. I don't get different results though.

            To assure that I have main.qml and PlayListOpenDialog.qml in the same folder, here's a screenshot of it https://www.dropbox.com/s/qqxifw2ora50yy7/all_in.png?dl=0 .

            Also, I have some other loaded components in main.qml. The component issued in the error message varies from a compilation to another. If that helps.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 25 Aug 2014, 08:09 last edited by
              #6

              OK, they are physically in the same folder. But are they all in the same folder inside the QRC file?

              (Z(:^

              1 Reply Last reply
              1
              • B Offline
                B Offline
                blueblood
                wrote on 25 Aug 2014, 08:35 last edited by
                #7

                Thanks, that worked.

                I added the components to qml.qrc file:

                @
                <file>main.qml</file>
                <file>PlaylistOpenDialog.qml</file>
                <file>PlaylistSaveDialog.qml</file>
                <file>TransferToDialog.qml</file>
                <file>AppMenuBar.qml</file>
                @

                It's strange that QtCreator didn't do that when I added them though.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sierdzio
                  Moderators
                  wrote on 25 Aug 2014, 08:40 last edited by
                  #8

                  [quote author="blueblood" date="1408955749"]It's strange that QtCreator didn't do that when I added them though.[/quote]

                  Not really, resource files are an option, not a requirement in Qt (and QML).

                  (Z(:^

                  1 Reply Last reply
                  1
                  • P Pl45m4 referenced this topic on 14 Feb 2023, 11:21

                  1/8

                  25 Aug 2014, 06:37

                  • Login

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