QT 添加启动画面
2010-08-17 00:38
302 查看
许多应用程序在启动时显示一个画面。在程序启动很慢时,程序员用这种方法可以让启动时间感觉不那么长,还有用这个画面满足市场的一些要求。给Qt应用程序加一个启动画面很简单,需要使用的类是QSplashScreen。
在窗口没有显示之前,QSplashScreen显示一个图片,他还可以在图片上显示文字信息提示用户当前程序初始化的进度。一般情况下,启动画面代码在main()函数中,加在调用QApplication::exec()之前。
下面的一个程序的main()函数使用QSplashScreen显示一个启动画面,同时显示加载的模块信息和网络连接情况。
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSplashScreen *splash = new QSplashScreen;
splash->setPixmap(QPixmap(":/images/splash.png"));
splash->show();
Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
splash->showMessage(QObject::tr("Setting up the main window..."),
topRight, Qt::white);
MainWindow mainWin;
splash->showMessage(QObject::tr("Loading modules..."),
topRight, Qt::white);
loadModules();
splash->showMessage(QObject::tr("Establishing connections..."),
topRight, Qt::white);
establishConnections();
mainWin.show();
splash->finish(&mainWin);
delete splash;
return app.exec();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/iamdbl/archive/2007/03/12/1526999.aspx
本文出自 “xiesiyuana的博客” 博客,请务必保留此出处http://seanyxie.blog.51cto.com/1319339/1376015
在窗口没有显示之前,QSplashScreen显示一个图片,他还可以在图片上显示文字信息提示用户当前程序初始化的进度。一般情况下,启动画面代码在main()函数中,加在调用QApplication::exec()之前。
下面的一个程序的main()函数使用QSplashScreen显示一个启动画面,同时显示加载的模块信息和网络连接情况。
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSplashScreen *splash = new QSplashScreen;
splash->setPixmap(QPixmap(":/images/splash.png"));
splash->show();
Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
splash->showMessage(QObject::tr("Setting up the main window..."),
topRight, Qt::white);
MainWindow mainWin;
splash->showMessage(QObject::tr("Loading modules..."),
topRight, Qt::white);
loadModules();
splash->showMessage(QObject::tr("Establishing connections..."),
topRight, Qt::white);
establishConnections();
mainWin.show();
splash->finish(&mainWin);
delete splash;
return app.exec();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/iamdbl/archive/2007/03/12/1526999.aspx
本文出自 “xiesiyuana的博客” 博客,请务必保留此出处http://seanyxie.blog.51cto.com/1319339/1376015
相关文章推荐
- qt添加程序启动画面
- QT添加程序启动画面
- QT 添加启动画面
- 自学qt之添加动作图标 程序启动画面
- Qt5 程序启动画面动图效果
- IOS编程教程(八):在你的应用程序添加启动画面
- vs2008 添加启动画面(基于对话框)
- Qt的启动画面
- VS2008中添加程序启动画面 splash screen
- iOS 应用添加启动画面以及App应用图标的方法
- Qt中实现启动画面
- Qt程序启动画面播放(gif与swf两种动画格式)
- 给程序添加启动画面(C#.net )
- 真正完美解决vs2008 添加启动画面(基于对话框)
- vc基于对话框的应用程序添加启动画面
- Qt启动画面(类似Office)
- 给 VS2008 / VS2010 MFC 项目添加启动画面
- iOS中为网站添加图标到主屏幕以及增加启动画面
- 轻松学习Ionic (四) 修改应用图标及添加启动画面(更新官方命令行工具自动生成)
- Qt中实现启动画面