Solve the problem that the QIcon icon does not display in Qt

Some icons are added to the image path, but they cannot be displayed using the QIcon method. Then I was wondering whether these pictures in qt need "declaration" like functions, so I searched through the project files one by one. Finally I found the qrc folder.
Insert picture description here
Although I added some files under the mode file, they are not reflected in the above qrc file. Insert picture description here
So I think, just import the image file into the qrc file.
So right-click /mode->add existing file.
Insert picture description here
Find the remotecontrol.jpg file in the resource/mode path
Insert picture description here
and add it, but it is not directly like chart and debug as I imagined, it is in a newly generated folder resource\mode file. Insert picture description here
It would be very inconvenient to call this way, what should I do? After some exploration, we can directly edit the qrc file.
Right-click the qrc file->Open in Editor->->/mode->Add Files->set alias,
Insert picture description here
so we have realized the addition of qrc resources. Insert picture description here
Then call it again. When calling, we can also call the alias directly!
Insert picture description hereSuccessfully displayed!
Insert picture description here
Insert picture description here
But the backgrounds of these pictures are not transparent, and setting not to display the background is useless. I have always had this trouble, because I found these pictures on the Internet, so how to change the background color to a transparent color, or how to ignore the background, feels a very strange question (which part is regarded as the background), about this Please see the next blog to solve the problem of Qt icon background color transparency
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_16488989/article/details/108826508