首页| 论坛| 消息

标题:【提问】求一个Qt 4下的程序起动时载入splash图象的例子。
作者:kytexzy
日期:2005-09-07 21:09
内容:

小弟我新学Qt,想求一个程序起动时载入splash图象的例子的,还请高人不吝赐教!


#1 [XChinux 09-07 23:44]
源代码包含七个源文件main.cpp是主函数。ex65.h和ex65.cpp,还有ex65.ui是主窗体文件,splashwindow.h, splashwindow.cpp和splashwindow.ui是Splash窗口。
在启动时,Splash窗口先出现,在用户点击用鼠标在窗口上点击一下后,Splash窗口消失,主窗口显示。
main.cpp
#include
#include "ex65.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ex65 w;
//w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
ex65.h
#ifndef EX65_H
#define EX65_H
#include
#include "ui_ex65.h"
#include "splashwindow.h"
class ex65 : public QWidget
{
Q_OBJECT
public:
ex65(QWidget *parent = 0);
~ex65();
private:
Ui::ex65Class ui;
SplashWindow *sp;
};
#endif // EX65_H
ex65.cpp
#include "ex65.h"
#include "splashwindow.h"
ex65::ex65(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
sp = new SplashWindow(this);
sp->show();
}
ex65::~ex65()
{
delete sp;
}
splashwindow.h
#ifndef SPLASHWINDOW_H
#define SPLASHWINDOW_H
#include
#include
#include "ui_splashwindow.h"
using namespace Ui;
class SplashWindow : public QDialog, public SplashWindowClass
{
Q_OBJECT
public:
SplashWindow(QWidget *parent = 0);
~SplashWindow();
private:
void mousePressEvent(QMouseEvent *);
};
#endif // SPLASHWINDOW_H
splashwindow.cpp
#include
#include
#include "splashwindow.h"

SplashWindow::SplashWindow(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
QImage image("splash.png");
label->setPixmap(QPixmap::fromImage(image));
resize(500, ..

回复 发表
主题 版块