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. Import QML File from QRC
Forum Updated to NodeBB v4.3 + New Features

Import QML File from QRC

Scheduled Pinned Locked Moved QML and Qt Quick
qrcqmlimport
5 Posts 2 Posters 4.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.
  • V Offline
    V Offline
    Vostro162
    wrote on last edited by
    #1

    Hello Guys,
    my main.qml is in qml.qrc// directory.
    my import file is also in this qrc directory.
    i try this paths
    import "qrc:/importFile.qml" as ImportFile
    import "qrc:///importFile.qml" as ImportFile
    import "importFile.qml" as ImportFile
    but is not working

    thanks in the advance for the help

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Leonardo
      wrote on last edited by
      #2

      If both qml files have the same prefix (in your case, /), you don't need to import it. Use the filename without extension to instantiate it.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vostro162
        wrote on last edited by
        #3

        yes both files have the prefix / but this path
        import "importFile.qml" as ImportFile
        is not working the error is that
        QML debugging is enabled. Only use this in a safe environment.
        QQmlApplicationEngine failed to load component
        qrc:///main.qml:4 "collectionView.qml": no such directory
        maybe i must change my main.cpp file ?

        1 Reply Last reply
        0
        • L Offline
          L Offline
          Leonardo
          wrote on last edited by
          #4

          Once again, you don't need to import it. You should be able to instantiate it without a problem.

          importFile {
               id: test
          }
          
          1 Reply Last reply
          0
          • V Offline
            V Offline
            Vostro162
            wrote on last edited by
            #5

            ahh okay thank you ^^

            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