zl程序教程

您现在的位置是:首页 >  工具

当前栏目

Qt 启动画面

Qt 启动 画面
2023-09-14 09:07:01 时间
int main(int argc, char *argv[]) 
{ 
    QApplication a(argc, argv); 
    //设置程序启动画面 
    QSplashScreen *splash = new QSplashScreen; 
    splash->setPixmap(QPixmap(":/p_w_picpaths/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(":/p_w_picpaths/7.bmp")); 
    MainWindow w; 
    w.show(); 
    splash->finish(&w);//将控制权交给mainWin窗体 
    delete splash; 
    return a.exec(); 
}