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. QResources relative path problem

QResources relative path problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 987 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.
  • ck_eeC Offline
    ck_eeC Offline
    ck_ee
    wrote on last edited by
    #1

    Hi,
    i want to use windows enviroment variables (a directory) in my QResources. I want to work with a central directory for all my pictures, icons and so on which is referenced by a enviroment variable.

    For example: "c:\bmp" contains all pictures. "BMP = C:\bmp" ist the enviroment variable/value. Is it possible to use this variable in the QResource system? I have read the documentation but couldn't find an anwser.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      It seems only to accept files directly.
      So you would have to add all in C:\bmp / whole folder.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        No you can't, the files you put in .qrc must be in the same folder as the .qrc file or in a subfolder within that folder.

        More information here

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • Paul ColbyP Offline
          Paul ColbyP Offline
          Paul Colby
          wrote on last edited by
          #4

          @ck_ee said:

          Is it possible to use this variable in the QResource system?

          As @SGaist said, not directly.

          However, you should be able to add a custom qmake target that creates a symbolic link to the $$(BMP) path under wherever your *.qrc file is.

          As far as I know, qmake has no built-in commands for creating symbolic links, so you'd have to implement per-platform commands; perhaps something like:

          win32-msvc: mybmptarget.commands = mklink /j $$(BMP) $$OUT_PWD/.../resources/bmp
          unix: mybmptarget.commands = ln -s $$(BMP) $$OUT_PWD/.../resources/bmp
          

          Cheers.

          1 Reply Last reply
          0
          • ck_eeC Offline
            ck_eeC Offline
            ck_ee
            wrote on last edited by
            #5

            ty for the tip :]

            finally this .pri file worked for me

            win32 {
                PRJ_DIR = $$OUT_PWD
                PRJ_DIR ~= s,/,\\,g
                BMP_DIR = $$(ENV_PATH)\bmp
                BMP_DIR ~= s,/,\\,g
            
                mybmptarget.commands = $$(ENV_PATH)\bmp\link.bat $$PRJ_DIR\bmp $$BMP_DIR
                mybmptarget.target = mybmptarget
                QMAKE_EXTRA_TARGETS += mybmptarget
                PRE_TARGETDEPS += mybmptarget
            }
            

            the link.bat contains:

            
            if not exist %1 (	
            	mklink /j %1 %2 
            )
            

            This allows me to use a global ressource folder which is referenced by a PATH variable.

            1 Reply Last reply
            1

            • Login

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