Important: Please read the Qt Code of Conduct -

Directorys are shown twice in qrc path

  • Hello dear community,

    In my application I am only using the qrc file system.

    This is my approach:

    1. I create a directory structure in my windows file system for my Qt Creator project.


    • /qml
      • /navigation
      • /settings@
    1. Then I create a new qml file and save it under the path "/qml/navigation" on my windows file system.
      I also want to have this windows file system structure in my Qt Creator project.
      Therefore I create a prefix for every directory in my windows file system structure

    @Resource Files

    • qml.src
      • /navigation
      • /settings@
    1. Add an existing qml file to the qrc file system.
      And here is the problem! The path to the file will be shown as below.

    @Resource Files

    • qml.src
      • /navigation
        • qml/navigation/navigationOverview.qml
      • /settings@

    If I want to use that file in another qml file I have to use this path:
    @... source: "qrc:///navigation/qml/navigation/navigationOverview.qml@

    What I want is only to write down the qrc file system path (without the windows file system path!):
    @... source: "qrc:///navigation/navigationOverview.qml@

    And the end I will have some paths like this:
    @... source: "qrc:///navigation/settings/overview/qml/navigation/settings/overview/navigationSettingsOverview.qml"@
    this really sucks..

    So the question is now: How can I achieve this?
    (Maybe I didn't understand how the qrc file system works?)

    Thanks for your answers!

  • Qt Champions 2017

    It is going to take the entire path like this. It is creating the relative path from the current directory in qrc. Assumption is that you would like continue the path structure you have put starting from your project location. It is like package system. If you don't want this kind of entire path, you can put the qmls in different directory and add them in QRC files.

  • Thanks for your fast reply!

    Unfortunately I dont understand excatly what you mean with:
    [quote author="Dheerendra" date="1408694784"]If you don't want this kind of entire path, you can put the qmls in different directory and add them in QRC files. [/quote]

    I thought I was already doing this?
    I just saved the qml files in different directorys on my windows and added them into one qrc-file. (And created a prefix for every directory on my windows)

  • Qt Champions 2017

    When you are adding the file, it takes the path from the current source directory.

    Here is documentation from Qt Resource file system.
    "The specified paths are relative to the directory containing the .qrc file. Note that the listed resource files must be located in the same directory as the .qrc file, or one of its subdirectories"

    If you don't want this relative path in QRC file, you can remove the entire path and keep only required file. Just open the QRC file in Qt creator->RightClick->Rename. Now you can remove the path you don't want.

    Hope this helps.

Log in to reply