0%

Qt如何编写程序启动界面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <QApplication>
#include <QSplashScreen>
#include <QDateTime>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QSplashScreen *splash = new QSplashScreen;

splash->setPixmap(QPixmap(":/images/china.jpg"));
//splash->setWindowFlags(Qt::WindowStaysOnTopHint);
splash->show();

splash->showMessage("Will start in 1 seconds",Qt::AlignTop,Qt::blue);

QDateTime n=QDateTime::currentDateTime();
QDateTime now;
do{
now=QDateTime::currentDateTime();
a.processEvents();
} while (n.secsTo(now)<=2);


splash->showMessage("Started...",Qt::AlignTop,Qt::blue);

do{
now=QDateTime::currentDateTime();
a.processEvents();
} while (n.secsTo(now)<=2);

MainWindow w;
w.show();
splash->finish(&w);
delete splash;

return a.exec();
}
处无为之事,行不言之教;作而弗始,生而弗有,为而弗恃,功成不居!

欢迎关注我的其它发布渠道