QT6 adds resource files to the project and references them in the ui interface

Take adding image resources as an example

Right-click the project name (not the top name) and click Add Existing File

Insert image description here
Although this method is added to the project, it cannot be referenced in the UI design interface. The main reason may be that the file is not put into the project resource file. The difference can be seen in the following way.

Click to add new file

Select qt resource file, click Select,
Insert image description here
and then get a .qrc resource file through the following settings.
Insert image description here
Right-click the resource file. The first type of added file is in the root directory of the qrc file. The second type can edit the path by yourself.
Insert image description here

Add pictures to components in UI interface

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_43794311/article/details/132570711