1. Create a. qrc Resource Description file For example, example. qrc: <! Doctype RCC> <RCC version = "1.0"> <Qresource> <File> images/copy.png </File> <File> images/cut.png </File> <File> images/new.png </File> <File> images/open.png </File> <File> images/paste.png </File> <File> images/save.png </File> </Qresource> </RCC> By default, the name used to access resources in an application is prefixed with/in the Resource description :/. For example:/images/cut.png. For other rules, see the QT document the QT resource system. 2. Use RCC to compile this file RCC-binary myresource. qrc-O myresource. RCC In this way, the compiled resource file is generated. 3. Use resource files (1) register resource files Qresource: registerresource ("/path/to/myresource. RCC "); (2) When using resources, we can use the resource path to directly initialize the qicon, qimage, or qpixmap. Cutact = new qaction (qicon (":/images/cut.png"), TR ("Cu & T"), this ); 4. Compile Resources in the qmake pro File 1. Add it to the Pro File Resources = application. qrc Qmake generates a qrc_application.cpp file by using the rule. Qrc_application.cpp contains all the data and has been registered. You can directly use the resources in it. All resources are arranged under a global resource tree. 5. Creating Resources in qdesigner is very simple. (1) Select create a resource file. qrc in the resource manager window, and save the file. (2) In the resource manager window, select Add Resource and file (the graphic file must be in the working directory and Its subdirectories), and then you can use the resource in the file. 6 Add in QT integrate vs 2003 A. qrc file is created when you create a new project. Double-click the file to open the resource configuration window. Configure the file in the configuration window. After the file is configured, you can directly use it in the code. |