Qt-QSplashScreen-program startup animation,
When most large applications are started, a startup screen is displayed before the program is fully started, and disappears after the program is fully started. The startup screen displays information about related products, it allows users to understand the product functions while waiting for the program to start. This is also a publicity method.
First run the interface
The following is the sample code.
Mainwindow. h
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include
class MainWindow : public QMainWindow{ Q_OBJECTpublic: MainWindow(QWidget *parent = 0); ~MainWindow();};#endif // MAINWINDOW_H
Mainwindow. cpp
# Include "mainwindow. h" # include
# Include
MainWindow: MainWindow (QWidget * parent): QMainWindow (parent) {setWindowTitle ("program startup screen example"); QTextEdit * edit = new QTextEdit; edit-> setText ("program startup screen example"); setCentralWidget (edit); resize (600,450); Sleep (1000);} MainWindow ::~ MainWindow (){}
The most critical core code
Main. cpp
#include "mainwindow.h"#include
#include
#include
int main(int argc, char *argv[]){ QApplication a(argc, argv); QPixmap pixmap("logo.jpg"); QSplashScreen splash(pixmap); splash.show(); a.processEvents(); MainWindow w; w.show(); splash.finish(&w); return a.exec();}