diff options
author | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2024-03-18 11:16:03 +0100 |
---|---|---|
committer | Cristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2024-03-19 13:09:05 +0100 |
commit | afbd87359bc5e959bac28cc0318794aa2231a91c (patch) | |
tree | 0444cee6f6b089fbe652d8ef91a3020931c27beb | |
parent | c2012a1cef6b916debab021fe316c4e2242b5ce3 (diff) |
doc: add page for pyside6-rcc
Adding a small description and a reference to our tutorial.
Change-Id: Ia3829d04cb824050023798078a1e23e7d0a5f471
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
-rw-r--r-- | sources/pyside6/doc/tools/pyside-rcc.rst | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/sources/pyside6/doc/tools/pyside-rcc.rst b/sources/pyside6/doc/tools/pyside-rcc.rst new file mode 100644 index 000000000..ee71500a7 --- /dev/null +++ b/sources/pyside6/doc/tools/pyside-rcc.rst @@ -0,0 +1,55 @@ +.. _pyside6-rcc: + +pyside6-rcc +=========== + +.. note:: This tool is automatically called by :ref:`pyside6-project` + so you don't need to call it manually. Qt Creator will take care + of this step as well while executing a project. + + +``pyside6-rcc`` is a command line tool for converting ``.qrc`` files into ``.py`` +files, so they can be used within your Python code. + +The tool is a wrapper around the `rcc`_ tool, which was originally +designed to generate C++ code, but it also has Python support. + +Even though the equivalent of ``pyside6-rcc`` is running ``rcc -g python`` +we strongly recommend you to rely on ``pyside6-rcc`` in order to avoid +mismatches between versions for the generated code. + +Usage +----- + +Once you have gathered your resources on a qrc file, +you can transform your ``.qrc`` file with the following command: + +.. code-block:: bash + + pyside6-rcc your_file.qrc -o rc_your_file.py + +It is important to use the ``-o`` option to generate the Python file with the +conversion, otherwise you will receive all the output as stdout in your terminal. + +To enable the usage of those resources in your program, you need to import +the file: + +.. code-block:: Python + + import rc_your_file + +then you can use a specific resource, for example an image, with the prefix ``:/``, +for example: + +.. code-block:: Python + + pixmap = QPixmap(":/icons/image.png") + + +For additional options, you can use ``pyside6-rcc -h`` in order to get +more information about additional options. + +Visit the tutorial :ref:`using_qrc_files` for a hands-on example. + +.. _`rcc`: https://doc.qt.io/qt-6/rcc.html + |