QMovie on QLabel starts not in full size

  • I use QMovie on QLabel and QGraphicsProxyWidget to show animated GIF over QGraphicsItem placed on QGraphicsScene. Almost all works fine except one - at first start I see not entire GIF but only small left part of it. After I drag QGraphicsItem over scene (QDrag is used for it) - then QMovie fully appears. Exactly QDrag carries just pointer to QGraphicsItem object instead of serialized object.

    All my actions I show here:
    QLabel* aniLabel = new QLabel();
    QMovie* aniMovie = new QMovie( ":/new/prefix1/anim-1-color.gif", QByteArray(), this );
    QGraphicsProxyWidget* aniWidget = new QGraphicsProxyWidget( this );
    aniLabel->setAttribute( Qt::WA_NoSystemBackground );
    aniLabel->setMovie( aniMovie );
    aniWidget->setWidget( aniLabel );

    these actions I perform in constructor of item class derived from QGraphicsItem. To setup position of QGraphicsProxyWidget on QGraphicsItem and show animation I use following code:
    aniWidget->setPos( pic.width() - aniLabel->size().width(),
    pic.height() - aniLabel->size().height() );

    it is placed in paint(...) event of item class derived from QGraphicsItem.

    My question is - are there some necessary actions to be done with QMovie before show it with QLavel? Or may be this is a problem with QLabel itself?

  • I SOLVED!! There is a bug in QMovie implementation. After first setting animated GIF it accepts size of only first frame. To properly initialize image properties from all frames QMovie must be started and stopped right now.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.