Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Splash screen in not showing in exec file
Forum Updated to NodeBB v4.3 + New Features

Splash screen in not showing in exec file

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 2.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vsukhwal
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! Please provide a minimal working example.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vsukhwal
        wrote on last edited by
        #3

        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
        

        }

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #4

          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

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          2
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2
            • V Offline
              V Offline
              vsukhwal
              wrote on last edited by VRonin
              #6

              @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;
              }
              
              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                IIRC png is a builtin format.

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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • V Offline
                  V Offline
                  vsukhwal
                  wrote on last edited by
                  #8

                  And it works! Path issue. thanks guys!

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    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 :)

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vsukhwal
                      wrote on last edited by
                      #10

                      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.

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Did you follow that guide ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved