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. Qrc : cannot find file/directory issues

Qrc : cannot find file/directory issues

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 7.7k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi All,

    I am working on a project in which all .cpp and .qml files are stored in the Qt Resource file(.qrc).
    I have tried to import an external directory in one of a qml file. The external directory contains
    other .qml files for different purposes.
    I don't want to include these external directory into the .qrc file.

    I got an error when i add the import path saying that "qrc:\example.qml : cannot find directory". Is there any way to include an external file or directory like this.

    Regards
    Ansif

    1 Reply Last reply
    0
    • sierdzioS Online
      sierdzioS Online
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Try with "file:/path" to tell QML you are breaking free from QRC. Or you can clear the context in the QML engine, but that will work only for Loader items.

      Why on Earthe do you include your c++ files in the QRC?

      (Z(:^

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi,

        Thanks for your reply. I will try this and will let you know. It was a mistake in my question, I included only .qml, javascript and image files in the QRC. Sorry for the mistake.

        Regards
        ansif

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Hi Again,

          I have tried to import like "#import "file:/../qml" as Tester" and i called Tester.PaletteModel {}, It shows an error like "qrc:/EditorPalette.qml:4:1: "file:/qml": no such directory ".

          EditorPAlette.qml is stored in the QRC and qml is the directory where PaletteModel.qml is the external file that is required.

          Regards
          ansif

          1 Reply Last reply
          0
          • sierdzioS Online
            sierdzioS Online
            sierdzio
            Moderators
            wrote on last edited by
            #5

            Sorry it's been almost 2 years since I had a similar problem, I don't remember a solution :( Try asking on interest mailing list, there are more Qt devs there.

            I vaguely recall that there were some updates in that area for QML2, if possible try this with Qt 5.1.

            (Z(:^

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Hi Slerdizlo,

              Recently i got a solution for the question that i have asked and I want to write it in here. May be some others are also got this issue,
              I got the solution from the Qt forum, http://qt-project.org/forums/viewthread/7047
              Thanks to Denis Kormalev, Volker and Brucewuu for solving this problem.

              If you can go through this link, you can easily understand it. For accessing any file outside QRC, use "absolute filepath" of the file.
              For example:
              In main.cpp file;
              QString path = QDir::currentPath(); //path where the exec is present
              if your file is in src/file.qml of exec folder, then you can access it like
              (path += "/src/file.qml";), now path is the absolute file path for file.qml. You can access it in any of the QRC file.
              QQuickView view;
              view.rootContext()->setContextProperty("myFile", path);
              view.setSource("qrc:/main.qml");

              In main.qml file:
              Loader
              {
              id: loadItem
              source: myFile
              }
              Item
              {
              Component.onCompleted: loadItem.item
              }

              Regards
              Ansif

              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