Results 1 to 4 of 4

Thread: How to place animated GIF on QGraphicsScene?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default How to place animated GIF on QGraphicsScene?

    I have QGraphicsScene with QGraphicsItem-s. Now I need add animated images to some items. I created aniGIFs but don't see how to "attach" them to items. There is a way to show animated GIFs via QLabel with QMovie inside. But QLabel requires QWidget at least to define where to draw QLabel. I do not have any QWidget inside scene. QWidget and QGraphicsItem are independent drawing essences. They cannot mix. I tried inherit from both classes but got lots of errors even after MOC compiler.

    How can I solve this? How animated GIF can be better placed on QGraphicsScene? Can this work if I create QWidget inside paint() event of my QGraphicsItem? Or there is any other lightweight way?

  2. #2
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default (SOLVED) Re: How to place animated GIF on QGraphicsScene?

    QMovie should be initialized with animated GIF, then QLabel::setMovie( QMovie ), QGraphicsProxyWidget must be initialized with parent QGraphicsItem then QGraphicsProxyWidget::setWidget( Qlabel). QGraphicsProxyWidget::setPos(X,Y) needed to set position of movie on QGraphicsItem. Finally call of QLabel::setAttribute(Qt::WA_NoSystemBackground) needed to allow transparent parts of GIF be transparent. All works.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: (SOLVED) Re: How to place animated GIF on QGraphicsScene?

    An alternative could be to use QMovie together with a QGraphicsPixmapItem and updating the item whenever the movie indicates a frame change.

    Cheers,
    _

Similar Threads

  1. best way for a own animated loader?
    By janton in forum Newbie
    Replies: 2
    Last Post: 28th February 2012, 19:52
  2. Replies: 3
    Last Post: 21st April 2009, 05:25
  3. Pb with animated gif on Mac os
    By mourad in forum Qt Programming
    Replies: 0
    Last Post: 17th April 2008, 13:38
  4. How to place contextmenu in QGraphicsScene?
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2007, 16:04
  5. animated gif's
    By :db:sStrong in forum Newbie
    Replies: 2
    Last Post: 31st May 2006, 15: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
  •  
Qt is a trademark of The Qt Company.