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] Qt Ressource from ABOVE directory
Forum Update on Tuesday, May 27th 2025

[Solved] Qt Ressource from ABOVE directory

Scheduled Pinned Locked Moved General and Desktop
ressource
3 Posts 2 Posters 953 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.
  • S Offline
    S Offline
    StephanWoebbeking
    wrote on last edited by StephanWoebbeking
    #1

    Hi everyone, nice appearance of the new system, I need some time to get to know the new structure though. ;)

    Nevertheless, questions about Qt still remain... In my application I need to use ressources. I have boiled down the problem a little bit and came to this: I use an icon from a directory that is child to the application's source directory. I have added it using the Qt Creator 3.1.1 to the "Ressourcendateien" .qrc file. When I look into the physical file it reports - among others - it like this: "<file>ServiceTools_Shared_QT/Standard/SennLogo.ico</file>" which is fine. The path I use to access the ressource in my program reads ":ServiceTools_Shared_QT/Standard/SennLogo.ico", seems to fit and everything works fine.

    However, due to the structure of my projects, this is a shared ressource, so I would like to use it from a directory that is NOT a child to the application's source. So the new path would be "<file>../ServiceTools_Shared_QT/Standard/SennLogo.ico</file>" and the file I use to access it in my source would change to "../ServiceTools_Shared_QT/Standard/SennLogo.ico" to keep the analogy. Unfortunately - without changing anything else - the icon will not be loaded when starting the application.

    Can you confirm that ressources have to be stored as a child to the application's source?
    I suppose it's correctly included by the linker(?), but can't be referred by something like ":../"?
    May there be a different way to get access to this ressource?

    A share of your experiences would be much appreciated, thanks in advance.

    Stephan

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Resources do not have to be in a child directory.
      I don't know if it's intended or a bug but you indeed can't access these resources with a path with "..".
      What you can do though is give it an alias, e.g.:

       <qresource prefix="/">
          <file alias="SennLogo.ico">../ServiceTools_Shared_QT/Standard/SennLogo.ico</file>
       </qresource>
      

      Then you can access it by ":/SennLogo.ico". Alias can be anything. Contain a path, no extension etc. Sorta an id.

      The other thing you can do is place the .qrc file along with the resources to avoid the ".." altogether. Since it's a shared resource the .qrc can be shared as well. You can have a separate, local .qrc file for resources specific to that single project.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        StephanWoebbeking
        wrote on last edited by
        #3

        Hey, great, thanks for the quick answer! This works, for everyone else who will have the same issue. I didn't find it before, but after your hints I figured that one can go to the .qrc file, perform a right click on it, open in editor and assign the alias directly to the ressource.

        Thanks,
        Stephan

        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