Qt contains graphic resources, and the compilation fails to be handled (the error content is: no rule to make target '****' needed by 'debug/qrc_****.cpp)

Solution 1: Delete the wrong item in the makefile

The idea of ​​this method is: (delete the picture with the problem, if the picture is needed in the subsequent sequence, just add the picture again)

1. Open the build-*****-Debug folder generated after Qt runs.

 2. Open the makefile.Debug file and find the **.png line that qt reported an error

Delete the relevant lines of code, save and recompile the project. Then an error will be reported

 

 At this time, open the Resource (resource editor) in Qt, then open the **.qrc file, and then find the **.png with the corresponding name, right-click the mouse, and select Remove (delete). Now run it just fine.

Method Two:

The idea is: delete the entire resource editor, and then add it again.

1. Open the ***.pro file in the Qt project, and delete "**.qrc" after RESOURCES +=.

2. Delete the build-****-Debug folder generated by debugging and compiling, and rebuild the project in Qt (Phenomenon: the added resources will not exist, the Qt project can run, but the corresponding image resources cannot be loaded).

3. Click the right mouse button on the project name, and re-add the ".qrc" resource file.

Add it again according to the original adding method (note: the name of the civilization must be exactly the same as before, otherwise the picture will not be loaded due to inconsistent paths).

 Method 3: (forced compilation and build)

This method is useless for me to test it myself, but some people mentioned it on the Internet. In summary, you can try it (after all, it is the easiest method and requires too many operations).

According to analysis on the Internet, the resource file resource.qrc has been compiled and generated, and deleting it in the resource resource directory cannot change the compiled resource.qrc, so this kind of error will occur.

The method is: right-click on the project name and click qamke. Then rebuild to resolve.

 

Guess you like

Origin blog.csdn.net/qq_54704926/article/details/127360256