My method is to add a label to the interface.
The GIF picture is then displayed in the label, and the dynamic picture size is the same as the label size
The first step is to add a resource file first
Then add the animated picture you want to play to the resource file
Then add a Label control to the interface, and the rest will write the code.
#include "widget.h" #include "ui_widget.h" #include <qmovie>widget::widget (Qwidget *parent): qwidget ( Parent), UI (new Ui::widget) { ui->setupui (this); Ui->label->setscaledcontents (true); Qmovie *movie = new Qmovie ("://images/06203988bec55a557c4f386b03d80176.gif"); Ui->label->setmovie (movie); Movie->start ();} Widget::~widget () { Delete ui;}
My interface is widget, so I added the label to the widget, so the code is also written in Widget.cpp
We need to add a Qmovie header file
Then new a movie, and then copy the address of the animated image to the movie in the resource file.
The rest should be read.
QT displays animated images in the interface