Qt uses Qmovie to load GIF images to implement a dynamic wait window

Source: Internet
Author: User

Sometimes to do a background processing, but the background processing time is very long, need to prompt the user to wait, may wish to do a dynamic waiting window. The specific implementation process is as follows:

1 Custom window class dlgwait (1) Add a animated GIF image to the resource, remembering its size.

I added is a "loading.gif" picture, size is 100x100, as follows:

(2) Add a window interface class dlgwait

Window size is slightly larger than GIF, such as 150x150

Add 2 Qlabel to the interface:

The first one to display the GIF, named Lbl_gif,text, is empty, and the size is 100x100

The second one, which is used to display the prompt message named lbl_text,text "in background processing, please wait"

As shown below:

(3) Set dlgwait window without border, background transparent effect, and load GIF picture

Add the following code to the Dlgwait constructor:

Setwindowflags (Qt::framelesswindowhint);//No BorderSetAttribute (qt::wa_translucentbackground);//Transparent Background//Center Screen Display  intFRMX =width (); intFrmy =height ();  Qdesktopwidget W; intDeskwidth =w.width (); intDeskheight =w.height (); Qpoint Movepoint (Deskwidth/2-FRMX/2, Deskheight/2-Frmy/2);  Move (Movepoint); //Loading GIF picturesQmovie*movie =NewQmovie (":/img/loading"); UI->lbl_gif->Setmovie (movie); Movie->start ();

2 Use the Wait window

The effect is as follows:

Qt uses Qmovie to load GIF images to implement a dynamic wait window

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.