Image is needed for a recent task. So I certainly put a bunch of images to the currentProgramThe result image cannot be displayed. After a day or two, consider whether the image size or resolution is a problem. I asked someone in the Forum and found the reason. Path reason. You only need to put the image under the debug file to display it. Read from othersArticle:
Qdir Dir;
Qstring Pathname;
Pathname = Dir. currentpath ();
Qdebug () <pathname;
The aboveCodeThe current working directory is displayed:"C:/users/admin/build-yinspect-SS-Debug"
I put the image in"C:/users/admin/build-yinspect-SS-Debug"
The image is displayed normally.
Later, I used a resource file to display images, so I added a resource file. But it is not shown. I will try again to get the resource file in a few days. Finally, we got it right.
1. Add a resource file, such as IMG. qrc.
2. Add a prefix, such as button
3. Add images. It is best to put your images in the program directory to facilitate the transfer process.
4. When using images, for example:Qicon(":/Button/Image/1.png")
I think there is an imagefile in the program directory and there is a 1.png image in it. Don't forget to add it.