Manage resources

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

To add new resources:

  1. Go to Project > Add New Item > Installed > Visual C++ > Qt.
  2. Select Qt Resource File.

    {Add New Item dialog}

  3. In Name, enter a name for the resource file.
  4. In Location, specify a location for the file.
  5. Select Add to create a .qrc file and to open it in the Qt Resource Editor.

    {Qt Resource Editor}

  6. To add resources to the file, select Add > Add Files.
  7. In Prefix, 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.

Add prefixes

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

See also Start Qt Resource Editor and The Qt Resource System.

© 2023 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.