Qt adds image resources

1. How to add pictures

a. Save the images in a file and load them at runtime.
b. Include the XPM file in the source code.
c. Use Qt's resource mechanism.

2. Use the Qt resource mechanism to add pictures

1. First put an images folder containing image files into the project directory.
images folder
insert image description here
insert image description here
2. In the resource project to be added, right-click the project name, select Add New File, and select: Qt->Qt Resource File.
insert image description here
3. Click the choose button, set the name
insert image description here
4. Click Next, and click Finish.
insert image description here
5. The resource file addition of the project is completed.
insert image description here
6. Add a prefix to the file. Adding a prefix can facilitate management. Click the Add button and choose to add a prefix. This text is prefixed with "/".
insert image description here
7. To add a picture file, click Add, click Add File to open images, select the file to be added, and click Open.
insert image description here
8. If the file list is the content of the red box on the left, you can choose to rebuild it to display it.
insert image description here

9. Use these images

a. ": + prefix name + file name";

b. Right-click the file to be used, and click Copy Path ":...".

reference

Guess you like

Origin blog.csdn.net/liuqingsongmsdn2014/article/details/131781435