Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Splash screen image is not showing up

$
0
0
(I am new Qt user) I am figuring out how to display the Splash screen, and came upon this code https://qt-project.org/forums/viewreply/57388/. Code seems to work fine, but splash image (splash.png) is not showing up. Instead, I am getting completely black screen(that covers the entire screen) for 3 seconds, it disappears and shows the main window. I have added data.qrc with image directory. Running on Windows 7, 64 bit. Here is a warning it is giving me Starting C:\Users\alex\Desktop\QT\build-Splash-Desktop_Qt_5_0_2_MSVC2012_64bit-Debug\debug\Splash... QImage::scaled: Image is a null image C:\Users\alex\Desktop\QT\build-Splash-Desktop_Qt_5_0_2_MSVC2012_64bit-Debug\debug\Splash exited with code 0 Thanks ! //main.cpp #include <QtCore> #include <QApplication> #include <QPixmap> #include <QSplashScreen> #include <QWidget> #include <QMainWindow> #include <QTimer> #include <QThread> #include <QDesktopWidget> #include <QPainter>   int main(int argc, char* argv[]) {  QApplication app(argc, argv);  QMainWindow* viewer = new QMainWindow();  QImage splashScrImage (":/images/splash.png");  QSize screenSize = QApplication::desktop()->geometry().size();  QImage splashScr (screenSize, QImage::Format_ARGB32_Premultiplied);  QPainter painter (&splashScr);  painter.fillRect(splashScr.rect(), Qt::black);  QImage scaled = splashScrImage.scaled(screenSize, Qt::KeepAspectRatio);  QRect scaledRect = scaled.rect();  scaledRect.moveCenter(splashScr.rect().center());  painter.drawImage(scaledRect, scaled);  QPixmap Logo;  Logo.convertFromImage(splashScr);  QSplashScreen splashScrWindow (viewer, Logo, Qt::WindowStaysOnTopHint);  splashScrWindow.move(0,0);  splashScrWindow.show();  QTimer::singleShot(3000, &splashScrWindow ,SLOT(close()));  viewer->show();  return app.exec(); } data.qrc file <RCC>     <qresource prefix="/">         <file>images/splash.png</file>     </qresource> </RCC> Splash.pro file   QT       += core gui   greaterThan(QT_MAJOR_VERSION, 4): QT += widgets   TARGET = Splash TEMPLATE = app     SOURCES += main.cpp   HEADERS  +=   FORMS    +=   RESOURCES += \     data.qrc   OTHER_FILES +=

Viewing all articles
Browse latest Browse all 13965

Trending Articles