自学QT之启动画面

启动画面是一个翻译,外国人可不是这么叫的。PS、WPS都有这个画面,其实他只是一闪而过的界面而已,你能够理解为loading,不过要实现PS、AutoCAD那种显示载入项的界面,则要复杂一些,咱们只是简单的显示一个图片。windows

基于mainwindow的一个类:函数

头文件没必要更改,mainwindow.cpp的内容以下:动画

#include "mainwindow.h"
#include <QTextEdit>
#include <windows.h>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowTitle("启动对话框");
    QTextEdit *edit=new QTextEdit;
    edit->setText("程序启动");
    setCentralWidget(edit);
    resize(600,450);
    Sleep(1000);
}

MainWindow::~MainWindow()
{

}


固然,main函数也要修改的,这里决定了显示的顺序:翻译

#include "mainwindow.h"
#include <QApplication>
#include <QPixmap>
#include <QSplashScreen>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QPixmap pixmap("Qt.png");
    QSplashScreen splash(pixmap);
    splash.show();
    a.processEvents();

    MainWindow w;
    w.show();
    splash.finish(&w);

    return a.exec();

}



运行的效果:code

相关文章
相关标签/搜索