在QGraphicsScene中增加一个gif,发现背景无法透明,以至于将底层的图片遮挡住了。
以为是gif本身的问题,经过检查,发现图片背景确实透明的,gif没有问题。
参考这位大佬的提示:
https://stackoverflow.com/questions/7238027/widget-background-not-transparent-when-using-qgraphicsview-but-transparent-when
Did you try using a stylesheet to set the background transparency?
yourWidget->setStyleSheet(“background-color: transparent;”);
问题得到解决。
解决后的效果:信号就是gif图。
QMovie *movie = new QMovie(fileName);
gif_anim->setMovie(movie);
gif_anim->setStyleSheet("background-color: transparent;");
movie->start();