pinkyuanxue的个人主页

一块来学习!!!

http://www.qtcn.org/bbs/u/126669  [收藏] [复制]

pinkyuanxue

奋斗.....

  • 23

    关注

  • 26

    粉丝

  • 39

    访客

  • 等级:新手上路
  • 总积分:9
  • 女,1990-01-28

最后登录:2013-07-11

更多资料

日志

Qt_程‍序启动画面

2012-03-30 16:27
Qt_程序启动画面
转自http://blog.csdn.net/gohome520/article/details/6569000
程序启动画面一般用于显示软件信息(名称、作者、版权等)以及减少程序加载过程中的枯燥感。
在Qt中,可以通过QSplashScreen类来为应用程序添加一个启动画面,它会在应用程序的主窗口出现前显示一个图片,并且可以在图片上显示想要输出的信息。

下面是一个简单的例子:

view plain
#include <QApplication>  
#include <QTextEdit>
#include <QSplashScreen>  
#include <QtTest>  
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::red);      
QTest::qSleep(3000);  
QTextEdit *textEdit = new QTextEdit;      
splash>showMessage(QObject::tr("Loading modules..."), topRight,     Qt::blue);  
QTest::qSleep(3000);  


textEdit->show();    
splash->finish(textEdit);  
    delete splash;    
return app.exec();
  }  


注意1:
启动画面图片是通过setPixmap()来指定的,在这里图片是一个资源,因此,需要把图片添加到资源文件(.qrc)中;否则,看不到启动画面。

注意2:
在例子程序中,使用了QTest::qSleep()函数,因此,需要包含头文件<QTest>,并在.pro文件中,加入
        CONFIG += qtestlib
分类:Qt 学习笔记|回复:2|浏览:1701|全站可见|转载
 
 
删除

淳于半邪:楼主的这个代码,偶几个月前也写过;嘿嘿!

2012-03-30 17:28 -

pinkyuanxue:是吗?我是看到了,就随手记了一下,省得用的时候再去找了。

2012-03-30 17:53

Powered by phpwind v8.7 Certificate Copyright Time now is:04-29 02:51
©2005-2016 QTCN开发网 版权所有 Gzip disabled