PDA

View Full Version : Supported image format for QMovie?



cookie1909
20th April 2009, 22:48
I have a simple tutorial with QMovie to display an animated gif image. I download the gif file from this link http://www.gifs.net/Animation11/Animals/Dogs/3d_dog_face.gif.

However calling movie->isValid() always returns false for me. What are the supported file types for QMovie? I thought animated GIF was one of them.

Thanks in advance for your help.


#include <QtGui/QApplication>
#include<QWidget>
#include<QHBoxLayout>
#include<QLabel>
#include<QMovie>
#include<QPushButton>
#include<QSlider>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QHBoxLayout *lay=new QHBoxLayout();
QPushButton *play=new QPushButton("PLAY");
QPushButton *stop=new QPushButton("STOP");
QSlider *slider=new QSlider();
slider->setMinimum(0);
slider->setMaximum(200);
QLabel *label=new QLabel;
QMovie *movie = new QMovie("anim03.gif");
if (movie->isValid())
label->setMovie(movie);
else
label->setText("asdfasdf");
QObject::connect(play,SIGNAL(clicked()),movie,SLOT (start()));
QObject::connect(stop,SIGNAL(clicked()),movie,SLOT (stop()));
QObject::connect(slider,SIGNAL(valueChanged(int)), movie,SLOT(setSpeed(int)));
lay->addWidget(label);
lay->addWidget(play);
lay->addWidget(stop);
lay->addWidget(slider);
win->setLayout(lay);
win->show();
return a.exec();
}

spirit
21st April 2009, 06:18
you can get supported formats by calling QMovie::supportedFormats.
btw, I can't load that image even in browser.

vasanth
21st April 2009, 07:30
here is the list of supported file formats

http://doc.trolltech.com/4.5/qimagereader.html#supportedImageFormats