user2328479
user2328479

Reputation: 63

Qt + gif + alpha

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.

Upvotes: 6

Views: 1355

Answers (1)

Dimitry Ernot
Dimitry Ernot

Reputation: 6584

You can set the Qt::WA_TranslucentBackground attribute to your QLabel to get a translucent background:

yourLabel->setAttribute( Qt::WA_TranslucentBackground, true );

Upvotes: 8

Related Questions