当前位置: 代码迷 >> 综合 >> QT之实现开机界面的两种方法
  详细解决方案

QT之实现开机界面的两种方法

热度:14   发布时间:2024-01-25 21:40:29.0

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();
}

实质上是一样的,官方的会更好点

  相关解决方案