Results 1 to 5 of 5

Thread: How to insert an animated picture (GIF) in a QLabel or other

  1. #1
    Join Date
    Jan 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to insert an animated picture (GIF) in a QLabel or other

    I have been trying to insert an animated picture GIF in a QLabel. I searched in Google to see how to do it (I am a newbie )
    I used this code:

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char* argv[])
    4. {
    5. QApplication app(argc, argv);
    6. QLabel w;
    7.  
    8. // On crée une vidéo. Ici, c'est un GIF
    9. QMovie movie("c:/Mickey-11.gif");
    10. // On l'associe à un label
    11. w.setMovie (&movie);
    12. // On lance la vidéo
    13. movie.start ();
    14.  
    15. w.show();
    16. return app.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 
    (from http://qt.developpez.com/faq/?page=animation#gif_anime)

    but it is not working. They mentioned compiling the GIF plugin but I didn't know how to do it.

    Thanx for your help
    Last edited by jpn; 13th January 2010 at 13:42.

  2. #2
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to insert an animated picture (GIF) in a QLabel or other

    You need a QMovie pointer in line 9
    try
    QMovie *movie = new QMovie("c:/Mickey-11.gif");

  3. #3
    Join Date
    Jan 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to insert an animated picture (GIF) in a QLabel or other

    I tried that but still nothing

  4. #4
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to insert an animated picture (GIF) in a QLabel or other

    You should have something like this:
    Qt Code:
    1. QLabel *w = new QLabel(this);
    2. w->setFrameStyle(QFrame::Panel | QFrame::Sunken);
    3. QMovie *movie = new QMovie("c:/Mickey-11.gif");
    4. w->setMovie (movie);
    5. movie->start ();
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to JD2000 for this useful post:

    for_hope (17th January 2010)

  6. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to insert an animated picture (GIF) in a QLabel or other

    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Insert picture in a form using label
    By cwnelatury in forum Newbie
    Replies: 14
    Last Post: 19th March 2010, 00:43
  2. Dynamic Animated QLabel
    By patrik08 in forum Qt-based Software
    Replies: 0
    Last Post: 30th May 2008, 19:38
  3. Pb with animated gif on Mac os
    By mourad in forum Qt Programming
    Replies: 0
    Last Post: 17th April 2008, 14:38
  4. Replies: 3
    Last Post: 4th June 2007, 10:51
  5. animated gif's
    By :db:sStrong in forum Newbie
    Replies: 2
    Last Post: 31st May 2006, 16:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.