How to make a transparent background in QLabel with QMovie? Gif already has set transparency. I need to do something like KamikadzeCat or Felix. It's cats, that do something on Homescreen. I tried to write:
QLabel lb;
QMovie mv1("ooo.gif");
lb.setMovie(&mv1);
mv1.start();
lb.setWindowFlags(Qt::FramelessWindowHint);
lb.show();
Also I tryed to write:
lb.setStyleSheet("background-color: rgba(225,255,255,0);");
Bur it's not working at all. if first time the label was with gray background, and in the second time I tried to write a lot of numbers in rgba, but it was useless.
GIF doesn't have an alpha channel like PNG, so you can't get smooth transparent edges. The alpha channel specifies how transparent each pixel is, so you could have half-transparent pixels for example. GIF on the other hand is limited to 8 bit colors and one of them is designated as the transparent color.
Unfortunately no, the GIF format doesn't support partial (alpha-channel) transparency, meaning any pixel can only be fully tansparent or fully opaque, so it's not possible to make partially transparent GIFs and achieve anti-aliasing effect against different backgrounds.
You can set the Qt::WA_TranslucentBackground attribute to your QLabel to get a translucent background:
yourLabel->setAttribute( Qt::WA_TranslucentBackground, true );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With