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/Anim...d_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.

Qt Code:
  1. #include <QtGui/QApplication>
  2. #include<QWidget>
  3. #include<QHBoxLayout>
  4. #include<QLabel>
  5. #include<QMovie>
  6. #include<QPushButton>
  7. #include<QSlider>
  8. int main(int argc, char *argv[])
  9. {
  10. QApplication a(argc, argv);
  11. QWidget *win=new QWidget();
  12. QPushButton *play=new QPushButton("PLAY");
  13. QPushButton *stop=new QPushButton("STOP");
  14. QSlider *slider=new QSlider();
  15. slider->setMinimum(0);
  16. slider->setMaximum(200);
  17. QLabel *label=new QLabel;
  18. QMovie *movie = new QMovie("anim03.gif");
  19. if (movie->isValid())
  20. label->setMovie(movie);
  21. else
  22. label->setText("asdfasdf");
  23. QObject::connect(play,SIGNAL(clicked()),movie,SLOT(start()));
  24. QObject::connect(stop,SIGNAL(clicked()),movie,SLOT(stop()));
  25. QObject::connect(slider,SIGNAL(valueChanged(int)),movie,SLOT(setSpeed(int)));
  26. lay->addWidget(label);
  27. lay->addWidget(play);
  28. lay->addWidget(stop);
  29. lay->addWidget(slider);
  30. win->setLayout(lay);
  31. win->show();
  32. return a.exec();
  33. }
To copy to clipboard, switch view to plain text mode