Qt 启动画面

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

本文来源: http://blog.csdn.net/lwk0552/article/details/8193900

 

 

你可能感兴趣的:(qt,启动画面)