QT之實現開機界面的兩種方法

1.官方示例

int main(int argc, char *argv[])
  {
      QApplication app(argc, argv);
      QPixmap pixmap(":/splash.png");
      QSplashScreen splash(pixmap);
      splash.show();
      app.processEvents();
      ...
      QMainWindow window;
      window.show();
      splash.finish(&window);
      return app.exec();
  }

2.使用定時器

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

    QPixmap pixmap(":/icon/qt.ico");
    QSplashScreen splash(pixmap);
    splash.show();

    QTimer::singleShot(1500, &splash, SLOT(hide()));
    QTimer::singleShot(2000, &w, SLOT(show()));

    //w.show();

    return a.exec();
}

實質上是一樣的,官方的會更好點

發佈了21 篇原創文章 · 獲贊 8 · 訪問量 5061
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章