QT displays animated images in the interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.