您的位置:首页 > 编程语言 > Qt开发

Qt Visual Studio Add-in:Managing Resources

2010-07-03 18:11 459 查看


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 .rcfiles, .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 .qrc file.

See the Qt Resource System document for more information.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: