Difference between revisions of "Documentation/Nightly/Developers/Build system/Qt resource files"

From Slicer Wiki
Jump to: navigation, search
(fix name of script in link (genpy s.b. genqrc))
(remove potentially confusing notice)
 
Line 5: Line 5:
 
Slicer includes a tool to generate <code>.qrc</code> files from resource directories. This convenience tool was created to simplify working with icons, which can require several entries per icon (one per available resolution) that may be cumbersome to write by hand.
 
Slicer includes a tool to generate <code>.qrc</code> files from resource directories. This convenience tool was created to simplify working with icons, which can require several entries per icon (one per available resolution) that may be cumbersome to write by hand.
  
The script ([https://github.com/Slicer/Slicer/blob/master/Utilities/Scripts/genqrc.py genqrc.py]) can be found in the [https://github.com/Slicer/Slicer/tree/master/Utilities/Scripts Utilities/Scripts] directory of the Slicer source.
+
The script ([https://github.com/Slicer/Slicer/blob/master/Utilities/Scripts/genpy.py genpy.py]) can be found in the [https://github.com/Slicer/Slicer/tree/master/Utilities/Scripts Utilities/Scripts] directory of the Slicer source.
  
 
The positional argument(s) to the script give a list of directories that should be scanned for resource files (e.g. <code>'Icons'</code>). An optional <code>-o</code> parameter may be used to specify the output file (otherwise the script will print to stdout). The script should normally be run in the directory of the desired output <code>.qrc</code> file in order to provide and generate relative paths that will be both understood correctly by the Qt resource compiler, and meaningful to other developers' checkouts.
 
The positional argument(s) to the script give a list of directories that should be scanned for resource files (e.g. <code>'Icons'</code>). An optional <code>-o</code> parameter may be used to specify the output file (otherwise the script will print to stdout). The script should normally be run in the directory of the desired output <code>.qrc</code> file in order to provide and generate relative paths that will be both understood correctly by the Qt resource compiler, and meaningful to other developers' checkouts.
Line 14: Line 14:
 
  cd Base/QTGUI/Resources
 
  cd Base/QTGUI/Resources
 
  ../../../Utilities/Scripts/genqrc.py -o qSlicerBaseQTGUI.qrc Icons
 
  ../../../Utilities/Scripts/genqrc.py -o qSlicerBaseQTGUI.qrc Icons
 
{{notice|The list of resource directories in the generated <code>.qrc</code> is printed using Python's representational format of a list of strings, which is ''not'' suitable for feeding to the shell directly. You should perform the necessary syntax conversion by hand when running the script. (Usually it is sufficient to remove the square brackets and commas.)}}
 
  
 
This tool is currently meant to be used in an "offline" manner (i.e. not part of the build process). When adding icons, you should re-run the script to generate an updated <code>.qrc</code> file and commit the updated file.
 
This tool is currently meant to be used in an "offline" manner (i.e. not part of the build process). When adding icons, you should re-run the script to generate an updated <code>.qrc</code> file and commit the updated file.

Latest revision as of 18:30, 9 June 2014

Home < Documentation < Nightly < Developers < Build system < Qt resource files


For the latest Slicer documentation, visit the read-the-docs.


Generating QRC Files: genqrc.py

Slicer includes a tool to generate .qrc files from resource directories. This convenience tool was created to simplify working with icons, which can require several entries per icon (one per available resolution) that may be cumbersome to write by hand.

The script (genpy.py) can be found in the Utilities/Scripts directory of the Slicer source.

The positional argument(s) to the script give a list of directories that should be scanned for resource files (e.g. 'Icons'). An optional -o parameter may be used to specify the output file (otherwise the script will print to stdout). The script should normally be run in the directory of the desired output .qrc file in order to provide and generate relative paths that will be both understood correctly by the Qt resource compiler, and meaningful to other developers' checkouts.

For example, to generate qSlicerBaseQTGUI.qrc, one would run:

cd /path/to/slicer/source
cd Base/QTGUI/Resources
../../../Utilities/Scripts/genqrc.py -o qSlicerBaseQTGUI.qrc Icons

This tool is currently meant to be used in an "offline" manner (i.e. not part of the build process). When adding icons, you should re-run the script to generate an updated .qrc file and commit the updated file.