#include <QMainWindow> class SplashScren : public QMainWindow { Q_OBJECT public: SplashScren(QWidget *parent = Q_NULLPTR); };
#include "SplashScreen.h" #include<QTextEdit> #include<windows.h> #pragma execution_character_set("utf-8") SplashScren::SplashScren(QWidget *parent) : QMainWindow(parent) { setWindowTitle("主界面"); QTextEdit *edit = new QTextEdit; edit->setText("hello world"); setCentralWidget(edit); resize(600,400); Sleep(1000); }
#include "SplashScreen.h" #include <QApplication> #include <QPixmap> #include <QSplashScreen> int main(int argc, char *argv[]) { QApplication a(argc, argv); QPixmap pixmap(":/SplashScreen/1"); QSplashScreen splash(pixmap); splash.show(); a.processEvents(); //使程序在显示启动画面的同时仍能响应鼠标等其他事件 SplashScren w; w.show(); splash.finish(&w); //在主窗口对象初始化完成后,结束启动画面 return a.exec(); }