But some problem persits.
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:
QGraphicsProxyWidget* aniWidget = new QGraphicsProxyWidget( this );
aniLabel->setAttribute( Qt::WA_NoSystemBackground );
aniLabel->setMovie( aniMovie );
aniWidget->setWidget( aniLabel );
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 );
To copy to clipboard, switch view to plain text mode
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() );
aniLabel->show();
aniMovie->start();
aniWidget->setPos( pic.width() - aniLabel->size().width(),
pic.height() - aniLabel->size().height() );
aniLabel->show();
aniMovie->start();
To copy to clipboard, switch view to plain text mode
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?
Added after 12 minutes:
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.
I did
aniMovie->start();
aniMovie->stop();
aniMovie->start();
aniMovie->stop();
To copy to clipboard, switch view to plain text mode
right before
aniLabel->setMovie( aniMovie );
aniLabel->setMovie( aniMovie );
To copy to clipboard, switch view to plain text mode
and animation now appears from first start.
Can anybody tell me - how QMovie works in Qt 5.x? Is start/stop needed to display animated GIF properly?
Bookmarks