打开一个软件,都会有启动画面。
现在去体验如何实现启动画面:输入图,装载,延时,下一张主部件图
在main。Cpp中实现启动时桌面图片。
#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QSplashScreen>//屏幕头文件
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
QPixmap pixmap("ee"); // 1,传图片
QSplashScreen splash(pixmap);//装载图
splash.show();//显示图
for(long index = 0; index < 1000000000; index++);//显示延时
splash.finish(&w);
w.show();
return a.exec();
}
1 QPixmap::QPixmap ( const char * const[] xpm )
Constructs a pixmap from the given xpm data, which must be a valid XPM image.
Errors are silently ignored.
Note that it's possible to squeeze the XPM variable a little bit by using an unusual declaration:
static const char * const start_xpm[]={
"16 15 8 1", "a c #cec6bd", 。。。。
1 ----------输入图:
Qpixmap类需要一些可用的图片,(.png),输入图片名,图存镜像文件夹下,传进来实现构造Qpixmap对象。
如:QPixmap pixmap("ee"); //传图片
2.
QSplashScreen::QSplashScreen ( const QPixmap & pixmap = QPixmap(), Qt::WindowFlags f = 0 )
Construct a splash screen that will display the pixmap.
There should be no need to set the widget flags, f, except perhaps Qt::WindowStaysOnTopHint.
This is illustrated in the following code snippet in which a splash screen is displayed and some initialization tasks are performed before the application's main window is shown:
2----------转载图:
传入照片后还是要构造一个溅起图片的媒介对象,就是需要利用第一个对象实现第二个对象的构造,用的时候把pixmap对象传给它,通常在main的主框之前显示
QSplashScreen splash(pixmap);//装载图
3
void | finish ( QWidget * mainWin ) |
Makes the splash screen wait until the widget mainWin is displayed before calling close() on itself.
3 -----关闭图:
显示主窗口前,闪屏会等到它出现再关闭自己
splash.finish(&w); //w是主布局的对象