Qt 启动画面

来源:互联网 发布:java输出星号金字塔 编辑:程序博客网 时间:2024/05/14 05:47

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
 //设置程序启动画面
 QSplashScreen *splash = new QSplashScreen;
 splash->setPixmap(QPixmap(":/images/j7.jpg"));//加载启动图片
 splash->show();
 Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
 splash->showMessage(QObject::tr("Setting up the main window..."),topRight,Qt::white);
 splash->showMessage(QObject::tr("Establishing connection..."),topRight,Qt::white);
 QDateTime n2 = QDateTime::currentDateTime();//获取当前时间;
 QDateTime now;
 do
 {
  now = QDateTime::currentDateTime();
 } while (n2.secsTo(now) <= 5);//设置启动时间(延时)为5秒
 a.setWindowIcon(QIcon(":/images/7.bmp"));
     MainWindow w;
    w.show();
 splash->finish(&w);//将控制权交给mainWin窗体
 delete splash;
    return a.exec();
}

--记录点点滴滴

原创粉丝点击