Splash screen in not showing in exec file



  • Hello there,

    I have created a splash screen which is shown on the launch of my project when I run my application in qt creator. However, when I try to click on the app.exe file in the release folder, my application launches without showing the splash screen. Can you please tell me why is this happening?

    I tried building my application several times and the behavior stays the same.

    Thanks,
    Vidushi


  • Moderators

    Hi! Please provide a minimal working example.



  • Also, I have added all the images in the resources folder. So that is also checked. Following is my code

    #include "home.h"
    #include "splashscreen.h"
    #include <QApplication>
    #include <QStyleFactory>
    #include <QDebug>
    #include "QsLog.h"
    #include "QsLogDest.h"
    #include "QsLogWindow.h"
    #include <QDir>
    #include <QSplashScreen>
    #include <QTimer>
    #include <QtNetwork>
    #include <QUrl>
    #include <QUrlQuery>
    #include <QJsonDocument>
    #include <QJsonParseError>
    #include <QJsonArray>
    #include <string>
    #include <QRect>

    void sendRequest();

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    //set the application icon and splash screen
    a.setWindowIcon(QIcon("./img/icon_2.png"));
    
    QPixmap splashImage("./img/icon_3.png");
    
    splashscreen* splash = new splashscreen(splashImage);
    
    
    QFont splashFont;
    splashFont.setFamily("Arial");
    splashFont.setBold(true);
    splashFont.setPixelSize(11);
    splashFont.setStretch(125);
    
    splash->setFont(splashFont);
    
    //    splash->setMask(splashMask);
    splash->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::SplashScreen);
    splash->show();
    
    a.processEvents();
    
    splash->showStatusMessage(QObject::tr("Initializing…"));
    
    sendRequest();
    
    a.processEvents();
    
    splash->showStatusMessage(QObject::tr("Getting user permissions and roles…"));
    
    Home w;
    w.ui->tabWidget->setStyle(QStyleFactory::create("Fusion"));
    
    QTimer::singleShot(2500,splash,SLOT(close()));
    QTimer::singleShot(2500,&w,SLOT(show()));
    //    w.show();
    
    return a.exec();
    

    }

    void sendRequest()
    {

    // http call
    

    }



  • what is splash? it's undeclared identifier in main
    If it's a QSplashScreen and you are setting a pixmap on it, make sure you deploy the imageformats plugin to handle the image format. for example, if you set a jpg as splash you have to deploy the qjpeg.dll


  • Lifetime Qt Champion

    Hi,

    To add to @VRonin your path is relative so you should also have the files in the proper place when you deploy your application. Or since it's a splash screen, you might want to embed it using Qt's resource system.



  • @SGaist : I have embedded it in the resources file as well explicitly and added a relative path. I can see my splash screen image in the img.qrc. Is there any other folder i need to put my file?

    @VRonin: Will i also have to include a dll associated to png image? splash is declared as an instance of splashcreen class. code of that class is as follows:

    #include "splashscreen.h"
    #include <QRect>
    #define COPYRIGHT_PREFIX 0xA9
    
    splashscreen::splashscreen(const QPixmap& pixmap)
    {
        QSplashScreen::setPixmap(pixmap);
    }
    
    splashscreen::~splashscreen()
    {
    }
    
    void splashscreen::drawContents(QPainter *painter)
    {
        QPixmap textPix = QSplashScreen::pixmap();
        painter->setPen(this->color);
        QString copyrightString;
        copyrightString.sprintf( "%c", COPYRIGHT_PREFIX);
    
        painter->drawText(QRect(200,253,415, 200), Qt::AlignLeft, "Version:  0.1\n\nCopyright"+copyrightString+" 2017-2018 Intel Corporation\n\nApplication suite:  METIS Client\n\n"+this->message);
    //    painter->drawText(QRect(200,453,415, 200), Qt::AlignLeft, this->message);
    
    //    painter->drawText(this->rect, this->alignement, this->message);
    }
    
    void splashscreen::showStatusMessage(const QString &message, const QColor &color)
    {
        this->message = message;
        this->color = color;
        this->showMessage(this->message, this->alignement, this->color);
    }
    
    void splashscreen::setMessageRect(QRect rect, int alignement)
    {
        this->rect = rect;
        this->alignement = alignement;
    }
    

  • Lifetime Qt Champion

    IIRC png is a builtin format.

    You still need to pass the correct path to your embedded file. Did you check that ?



  • And it works! Path issue. thanks guys!


  • Lifetime Qt Champion

    You're welcome !

    Since you have it working now, please mark the thread as solved using the *Topic Tools" button so that other forum users may know a solution has been found :)



  • Hey guys,

    I was able to see the icons and splash screen when i launched my application using the .exe file in the release folder finally. However, I faced another issue when I packed my file for distribution (using innosetup). When I installed the packaged file, I was not able to see the icon I created on the desktop icon and the task bar(once open).

    This problem was not there before the packaging.


  • Lifetime Qt Champion

    Did you follow that guide ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.