Qt中的GIF动画

2021-12-09 00:00:00 qgraphicsview qt c++

我使用了 QGraphicsViewQGraphicsScene 类来在这样的小部件中显示图片:

I have used QGraphicsView, QGraphicsScene classes in order to show a picture in a widget like this:

m_Scene->addPixmap(QPixmap(fileName));
m_View->setScene(m_Scene);

如何在同一场景中显示 .gif 动画?

How I can show .gif animation in the same scene?

推荐答案

我不将 GIF 动画与 QGraphicsViewQGraphicsScene 一起使用,我只在 中使用它>QDialog,但我认为这是相同的东西,所以这是我的代码:

I don't use GIF animation with QGraphicsView or QGraphicsScene, I use it only in QDialog, but I think it's the same stuff, so here is my code:

QMovie *movie = new QMovie(":/images/other/images/16x16/loading.gif");
QLabel *processLabel = new QLabel(this);
processLabel->setMovie(movie);
movie->start();

我的 loading.gif 我取自 this 链接.

My loading.gif I took from this link.

PS:还可以查看 Qt SDK 中的示例.他们真的能帮上忙!

PS: also check the examples from Qt SDK. They are really can help!

相关文章