Я тоже сталкивался с такой же проблемой раньше, надеюсь, это поможет вам
Заголовочный файл
#ifndef MYSPLASH_H
#define MYSPLASH_H
#include <QObject>
#include <QSplashScreen>
class MySplash : public QSplashScreen
{
public:
MySplash(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = Qt::WindowFlags());
bool eventFilter(QObject *target, QEvent *event);
};
#endif // MYSPLASH_H
Файл CPP
#include "mysplash.h"
#include <QEvent>
#include <QDebug>
MySplash::MySplash(const QPixmap &pixmap, Qt::WindowFlags f)
{
this->setPixmap(pixmap);
this->installEventFilter(this);
}
bool MySplash::eventFilter(QObject *target, QEvent *event)
{
Q_UNUSED(target)
if((event->type() == QEvent::MouseButtonPress) ||
(event->type() == QEvent::MouseButtonDblClick) ||
(event->type() == QEvent::MouseButtonRelease) ||
(event->type() == QEvent::KeyPress) ||
(event->type() == QEvent::KeyRelease))
return true;
return false;
}
В main.cpp вы можете добавить эти строки
// Splash Screen
MySplash *splash = new MySplash(QPixmap(":/Images/SplashScreen.png"));
splash->show();
a.processEvents();
// Start the application
HomePage w;
w.showMaximized();
// Finish
splash->finish(&w);
delete splash;
a.processEvents();
return a.exec();