Managing Resources

Adding new resources to a Qt project is similar to adding resources to a normal C++ project. The main difference is that .qrc files (Qt resource files) are used instead of Windows .rc files. Unlike .rc files, .qrc files work on all platforms supported by Qt and are trivial to load from Qt code.

Qt Resource Editor dialog

To add new resources:

  1. Select Project > Add New Item > Installed > Visual C++ > Qt > Qt Resource File.
  2. In the Name field, enter a name for the resource file.
  3. In the Location field, specify a location for the file.
  4. Select Add to create a .qrc file and to open it in the Qt Resource Editor.
  5. To add resources to the file, select Add > Add Files.
  6. In the Prefix field, you can change the prefix.

When referring to the resources later on from Qt code, you must prepend the prefix, the file name, and a colon. For example, :/MyProject/print.bmp.

To add prefixes to the .qrc file, select Add > Add Prefix in the Qt Resource Editor.

For more information, see The Qt Resource System.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.