我有这段代码,我希望它能展示一个启动画面,因为它会变得更大一些。我已经做了一个计时器,所以可以看到启动画面正在工作。问题是我没有看到启动画面,但是代码在运行,而启动画面没有出现,直接跳转到主窗口而没有显示启动画面。
下面是我的代码。
命令的运行方式是这样的,它们在运行之前不会显示闪屏,这个问题我找不到解决方法。
[编辑] 闭包对应的代码部分被放错了位置,即使放到正确的位置后仍然无法正常工作。
main.cpp
#include <iostream>
#include <QApplication>
#include <quazip/quazip.h>
#include "splashwindow.h"
#include "mainwindow.h"
#include "database.h"
int main(int argc, char *argv[])
{
/* Define the app */
QApplication app(argc, argv);
/* Define the splash screen */
SplashWindow splashW;
/* Show the splash screen */
splashW.show();
/* Download the database */
/* Define the database */
Downloader db;
/* Donwloading the database */
db.doDownload();
/* Unzip the database */
/* Define the database */
//Unzipper uz;
//uz.Unzip();
for(int i = 0; i < 1000000; i++)
{
cout << i << endl;
}
/* Close the splash screen */
splashW.hide();
splashW.close();
/* Define the main screen */
MainWindow mainW;
/* Show the main window */
mainW.showMaximized();
return app.exec();
}
splashwindow.cpp
#include <iostream>
#include <QStyle>
#include <QDesktopWidget>
#include "splashwindow.h"
#include "ui_splashwindow.h"
#include "database.h"
/* Splash screen constructor */
SplashWindow::SplashWindow (QWidget *parent) :
QMainWindow(parent), ui(new Ui::SplashWindow)
{
ui->setupUi(this);
/* Set window's flags as needed for a splash screen */
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::SplashScreen);
}
/* Splash screen destructor */
SplashWindow::~SplashWindow()
{
delete ui;
}
splashwindow.h
#ifndef SPLASHWINDOW_H
#define SPLASHWINDOW_H
#include <QMainWindow>
namespace Ui {
class SplashWindow;
}
class SplashWindow : public QMainWindow
{
Q_OBJECT
public:
explicit SplashWindow(QWidget *parent = 0);
~SplashWindow();
private:
Ui::SplashWindow *ui;
};
#endif // SPLASHWINDOW_H
命令的运行方式是这样的,它们在运行之前不会显示闪屏,这个问题我找不到解决方法。
[编辑] 闭包对应的代码部分被放错了位置,即使放到正确的位置后仍然无法正常工作。