Adding new resources to a Qt project is similar to adding resources to a normal C++ project, the main difference being that
.qrc files (Qt resource files) are used instead of Windows
.rc files. Unlike
.qrc files work on all platforms supported by Qt and are trivial to load from Qt code.
To add new resources, you must first create a new
.qrc file. To do this, open the Add New Item dialog, select Qt Resource File from the Qt Project Items folder, and click Open. The newly created
.qrc file will be displayed in the Qrc Editor, which is part of the Add-in installation.
At this point, the
.qrc file only contains a prefix named after the project. You can add resources under that prefix by selecting it and clicking on the Add button on the right hand side. Then click Add File in the context menu. Now the Resource Editor will display a dialog that allows you to add an existing file.
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. Using the context menu, you can rename the predefined prefix or add other prefixes to the
For more information see the Qt resource system topic.
© 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.