Nar*_*rek 23 c++ qt qgraphicsview
我已经使用QGraphicsView,QGraphicsScene类为了显示在这样的小部件的图片:
m_Scene->addPixmap(QPixmap(fileName));
m_View->setScene(m_Scene);
Run Code Online (Sandbox Code Playgroud)
如何在同一场景中显示.gif动画?
mos*_*osg 71
我没有使用GIF动画,QGraphicsView或者QGraphicsScene我只使用它QDialog,但我认为它是相同的东西,所以这是我的代码:
QMovie *movie = new QMovie(":/images/other/images/16x16/loading.gif");
QLabel *processLabel = new QLabel(this);
processLabel->setMovie(movie);
movie->start();
Run Code Online (Sandbox Code Playgroud)
我loading.gif从这个链接中拿走了.
PS:还要查看Qt SDK中的示例.他们真的可以帮忙!
Ade*_*ost 21
我把它放在这里以防万一我以外的人遇到同样的问题.
问题
GIF不会加载和isValid()返回false.
码
// Load animated GIF
QMovie* movie = new QMovie("foo.gif");
// Make sure the GIF was loaded correctly
if (!movie->isValid())
{
// Something went wrong :(
}
// Play GIF
QLabel* label = new QLabel(this);
label->setMovie(movie);
movie->start();
Run Code Online (Sandbox Code Playgroud)
解
为了解决这个问题,我不得不将Qt的GIF插件qgif4.dll放在imageformats我的exe旁边的文件夹中才能使用GIF.
dll可以在下面找到
/plugins/imageformats/qgif4.dll.