Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Animated gif inside QLabel not be drawn transparently
I have a QWidget 'A' with a background-image set in its stylesheet - nothing else is drawn on it. On top of the QWidget I have a QLabel widget (children of the 'A') with background set to Transparent. I'm playing an animated gif inside this QLabel using QMovie, the gif itself has transparency (spinner effect).
When I run the application it looks like the spinner is continuously being drawn on itself without background of the parent being re-drawn first? Then I just tried displaying a text in the Label, but even with just text, the background of the parent is Not being drawn. How do I fix these issues?
Make sure your stylesheet doesn't also affect the Label by using
too broad selector.
Works fine for fast test.
I was able to solve the background not drawing issue by painting the jpg manually - I had to do it because I wanted to custom fit the background.
The issue I'm seeing now are the white areas around the edges, as you see in your gif as well. Looks like the edges are not per-pixel alpha-blended with the background?
Nope, its not. Gif cannot do multilevel transparency.
Taytoo last edited by Taytoo
@mrjj Any ideas, how to fix this/workarounds?
Found this answer on stackoverflow: https://stackoverflow.com/questions/24592918/gif-image-in-qlabel
Although it was related to Graphics Scene, I tried it out, still no luck :(
@Taytoo you could potentially do it manually.
Save the gif frames as images, overwrite the paint event and draw one of the images. Set a timer to change the image periodically.