Qt startup interface design and Qt startup Interface Design

Source: Internet
Author: User

Qt startup interface design and Qt startup Interface Design

More and more find that the function of Qt is very powerful, and really like it more and more. For large projects, many modules and initialization operations need to be loaded when the program starts, and sometimes it may take a long time. As a result, users may not be able to wait, I feel that the program has been up for so long. To this end, many large programs have launched interfaces to mask module loading.

There are three main types of interface loading: static images, dynamic images (gif), and animations (swf ). Below is a simple study of these types.

I. Loading Static Images

Loading static images is also very simple for the first time to learn this. The basic idea is to make an image come true, and then delay makes people feel like a startup interface appears. Because the image is not good, you can directly upload the code.

<Strong> QSplashScreen splash (QPixmap (":/images/splash.png"); splash. setDisabled (true); // splash corresponding to the input event of the base user. show ();. processEvents (); splash. showMessage (QObject: tr ("data loading ...... "), Qt: AlignLeft | Qt: AlignBottom, Qt: black); for (int I = 0; I <200; I ++) {} splash. finish (mainwow); a.exe c (); </strong>
The QsplanshScreen class comes with Qt and requires header files. In this case, you need to add the prepared image to the resource file. Here, the Resource Name Is images. It is very easy to create a resource file, the master needs to click "file"-"New file or project"-"Qt resource file", and then give a name to add your own images to it. Here is nothing more to say.

Qt: AlignBottom, Qt: black is a piece of real-world prompt, reminding the user that the program is loading. You can set its font, color, size, and other information.

Ii. dynamic image loading

First, you have to prepare a dynamic image. You can make it yourself or download it. It can be made online. This is the easiest way to make one that you like.


<Strong> <span style = "font-size: 18px;"> QMovie * move = new QMovie (":/images/splash.gif "); QLabel * label = new QLabel ("", 0); label-> setGeometry (510,300,450,100); label-> setMovie (move); move-> start (); label-> setWindowFlags (Qt: FramelessWindowHint); // hide the border label-> show (); QTime t; t. start (); while (t. elapsed () & lt; 2000) {. processEvents () ;}</span> </strong>
It shows one of my start interfaces. Since it can only be static, my start is always dynamic.

My interface shows a dynamic image. If you make it yourself, you can simply make one. The Code should be easy to understand without too much explanation.

Iii. animation Loading

Animation loading is relatively difficult and requires plug-ins, which are actually the QAxWidget class in the Qt library. Directly add the code

<Strong> <span style = "font-size: 18px;"> QAxWidget * flash = new QAxWidget (0, 0 ); // QAxWidget uses the ActiveX plug-in flash-> resize (600,600); // you can specify the initial size of the widget in flash-> setControl (QString :: fromUtf8 ("{d27cdb6e-ae6d-11cf-96b8-444553540000}"); // sets the Controller flash-> dynamicCall ("LoadMovie (long, string)", 0, ": images/flash1.swf "); // flash-> setWindowFlags (Qt: FramelessWindowHint); // remove the border flash. show (); QTime t; t. start (); while (t. elapsed () <5000) {QApplication: processEvents ();} flash. close (); </span> </strong>

The code looks clear and easy to understand. You do not need to explain it too much.

Related Article

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.