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. SplashScreen stay on TaskManager

SplashScreen stay on TaskManager

Scheduled Pinned Locked Moved Unsolved General and Desktop
splashscreentask manager
29 Posts 3 Posters 9.7k Views
  • 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.
  • Q Offline
    Q Offline
    QtA_
    wrote on 1 Jan 2017, 16:53 last edited by QtA_ 1 Jan 2017, 16:58
    #1

    Hi All,..first, Happy New year to all :)

    I'm brand new with Qt,...no experience for now,..but I learn fast. :)

    I'm experimenting my first Qt application wich is to show only a splash screen.
    but the program remain in task manager..

    here the code.

    //#include "mainwindow.h"
    #include <QApplication>
    #include <QSplashScreen>
    #include <QTimer>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        QSplashScreen *splash=new QSplashScreen;
        splash->setPixmap(QPixmap ("C:/Users/public/test/Logo.png"));
        splash->show();
        QTimer::singleShot(2500,splash,SLOT(close()));
        return a.exec();
     
    }
    

    not sure to understand all,...for now I see 28 video tutorial on youtube..
    and want to learn more about this.

    thank you for your help.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 1 Jan 2017, 16:57 last edited by
      #2

      Hi and welcome
      so the timer that calls close , it not working`?

      Q 1 Reply Last reply 1 Jan 2017, 17:01
      0
      • M mrjj
        1 Jan 2017, 16:57

        Hi and welcome
        so the timer that calls close , it not working`?

        Q Offline
        Q Offline
        QtA_
        wrote on 1 Jan 2017, 17:01 last edited by
        #3

        @mrjj said in SplashScreen stay on TaskManager:

        Hi and welcome
        so the timer that calls close , it not working`?

        Thank you,..

        yes all seem to work fine,....except that the application stay in my Task manager.
        :\

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 1 Jan 2017, 17:10 last edited by mrjj 1 Jan 2017, 17:11
          #4

          Oh. that way.
          Well you dont have a MainWindow.
          QApplication will close application when the last window is closed.
          Not sure it knows about QSplashScreen.

          But when you dont have any mainwindow/top level widgets, it keeps running.

          You can make it exit calling quit() but its hard with just a QSplashScreen.

          So as you see in tut 28. he does have Mainwindow also ?

          Q 1 Reply Last reply 1 Jan 2017, 17:14
          1
          • M mrjj
            1 Jan 2017, 17:10

            Oh. that way.
            Well you dont have a MainWindow.
            QApplication will close application when the last window is closed.
            Not sure it knows about QSplashScreen.

            But when you dont have any mainwindow/top level widgets, it keeps running.

            You can make it exit calling quit() but its hard with just a QSplashScreen.

            So as you see in tut 28. he does have Mainwindow also ?

            Q Offline
            Q Offline
            QtA_
            wrote on 1 Jan 2017, 17:14 last edited by
            #5

            @mrjj said in SplashScreen stay on TaskManager:

            Oh. that way.
            Well you dont have a MainWindow.
            QApplication will close application when the last window is closed.
            Not sure it knows about QSplashScreen.

            But when you dont have any mainwindow/top level widgets, it keeps running.

            You can make it exit calling quit() but its hard with just a QSplashScreen.

            So as you see in tut 28. he does have Mainwindow also ?

            yes the tutorial have windows application...
            but I don't need it..

            in fact my project is simple,...
            I want to make a splashscreen with PNG transparency,..(without windows form)
            so I don't know if this is the way to go for it..

            I want to start with this,..and then,..add features...to be customized,.like time delay, fadein/fadeout, animated PNG etc...

            M 1 Reply Last reply 1 Jan 2017, 17:20
            0
            • Q QtA_
              1 Jan 2017, 17:14

              @mrjj said in SplashScreen stay on TaskManager:

              Oh. that way.
              Well you dont have a MainWindow.
              QApplication will close application when the last window is closed.
              Not sure it knows about QSplashScreen.

              But when you dont have any mainwindow/top level widgets, it keeps running.

              You can make it exit calling quit() but its hard with just a QSplashScreen.

              So as you see in tut 28. he does have Mainwindow also ?

              yes the tutorial have windows application...
              but I don't need it..

              in fact my project is simple,...
              I want to make a splashscreen with PNG transparency,..(without windows form)
              so I don't know if this is the way to go for it..

              I want to start with this,..and then,..add features...to be customized,.like time delay, fadein/fadeout, animated PNG etc...

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 1 Jan 2017, 17:20 last edited by
              #6

              @QtA_
              Ok, "(without windows form)" means with no borders or caption etc?

              I think you can use splashscreen for this but not sure its really needed.

              Will it be sort of a class others can use , as a super splashscreen thing or
              what is the goal ?

              Well you current issue can be fixed by calling apps quit() when you want the app to exit.
              like 2 timers. one call close for splashscreen and other call quit()
              but it all depends on how u want it to work.

              Q 1 Reply Last reply 1 Jan 2017, 17:31
              0
              • M mrjj
                1 Jan 2017, 17:20

                @QtA_
                Ok, "(without windows form)" means with no borders or caption etc?

                I think you can use splashscreen for this but not sure its really needed.

                Will it be sort of a class others can use , as a super splashscreen thing or
                what is the goal ?

                Well you current issue can be fixed by calling apps quit() when you want the app to exit.
                like 2 timers. one call close for splashscreen and other call quit()
                but it all depends on how u want it to work.

                Q Offline
                Q Offline
                QtA_
                wrote on 1 Jan 2017, 17:31 last edited by
                #7

                @mrjj said in SplashScreen stay on TaskManager:

                @QtA_
                Ok, "(without windows form)" means with no borders or caption etc?

                I think you can use splashscreen for this but not sure its really needed.

                Will it be sort of a class others can use , as a super splashscreen thing or
                what is the goal ?

                Well you current issue can be fixed by calling apps quit() when you want the app to exit.
                like 2 timers. one call close for splashscreen and other call quit()
                but it all depends on how u want it to work.

                that's why I'm here :)

                I'm a biginner with C++, so need to understand manything actually.
                my english is also not very good, but its ok I think. :)

                The goal should be something like this:

                1. create an EXE allowing parameters to show splashscreen.

                ex:
                mysplash.exe "c:/my images/logo1.png" /d:3 /fi:1 /fo:1

                wich:
                /d = delay
                /fi = fade in time delay
                /fo = fade out time delay

                then,...few version after,...allowing to execute splash with mutliple image running to make an animated splash with PNG files.. :)

                M 1 Reply Last reply 1 Jan 2017, 17:36
                0
                • Q QtA_
                  1 Jan 2017, 17:31

                  @mrjj said in SplashScreen stay on TaskManager:

                  @QtA_
                  Ok, "(without windows form)" means with no borders or caption etc?

                  I think you can use splashscreen for this but not sure its really needed.

                  Will it be sort of a class others can use , as a super splashscreen thing or
                  what is the goal ?

                  Well you current issue can be fixed by calling apps quit() when you want the app to exit.
                  like 2 timers. one call close for splashscreen and other call quit()
                  but it all depends on how u want it to work.

                  that's why I'm here :)

                  I'm a biginner with C++, so need to understand manything actually.
                  my english is also not very good, but its ok I think. :)

                  The goal should be something like this:

                  1. create an EXE allowing parameters to show splashscreen.

                  ex:
                  mysplash.exe "c:/my images/logo1.png" /d:3 /fi:1 /fo:1

                  wich:
                  /d = delay
                  /fi = fade in time delay
                  /fo = fade out time delay

                  then,...few version after,...allowing to execute splash with mutliple image running to make an animated splash with PNG files.. :)

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 1 Jan 2017, 17:36 last edited by
                  #8

                  @QtA_
                  ahh, sort of fancy app loader. :)
                  well that is a fun project.

                  You english is fine. :)

                  That should be possible for a first project. Good luck and feel free to ask.

                  Q 1 Reply Last reply 1 Jan 2017, 17:38
                  0
                  • M mrjj
                    1 Jan 2017, 17:36

                    @QtA_
                    ahh, sort of fancy app loader. :)
                    well that is a fun project.

                    You english is fine. :)

                    That should be possible for a first project. Good luck and feel free to ask.

                    Q Offline
                    Q Offline
                    QtA_
                    wrote on 1 Jan 2017, 17:38 last edited by
                    #9

                    @mrjj said in SplashScreen stay on TaskManager:

                    @QtA_
                    ahh, sort of fancy app loader. :)
                    well that is a fun project.

                    You english is fine. :)

                    That should be possible for a first project. Good luck and feel free to ask.

                    Thank you very much,..
                    I'm a fancy girl :)

                    return a.quit();
                    

                    do not close the process,..do I miss something ?

                    M 1 Reply Last reply 1 Jan 2017, 17:40
                    0
                    • Q QtA_
                      1 Jan 2017, 17:38

                      @mrjj said in SplashScreen stay on TaskManager:

                      @QtA_
                      ahh, sort of fancy app loader. :)
                      well that is a fun project.

                      You english is fine. :)

                      That should be possible for a first project. Good luck and feel free to ask.

                      Thank you very much,..
                      I'm a fancy girl :)

                      return a.quit();
                      

                      do not close the process,..do I miss something ?

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 1 Jan 2017, 17:40 last edited by mrjj 1 Jan 2017, 17:43
                      #10

                      @QtA_
                      Hi
                      do you now have
                      return a.exec();
                      return a.quit();

                      ?

                      it stays inside a.exec().

                      you can try
                      QTimer::singleShot(2500,&app,SLOT(quit()));
                      should kill it all after 2,5 secs.
                      U must keep return a.exec(); to use timers. Its drives the eventloop :)

                      Q 1 Reply Last reply 1 Jan 2017, 17:43
                      0
                      • M mrjj
                        1 Jan 2017, 17:40

                        @QtA_
                        Hi
                        do you now have
                        return a.exec();
                        return a.quit();

                        ?

                        it stays inside a.exec().

                        you can try
                        QTimer::singleShot(2500,&app,SLOT(quit()));
                        should kill it all after 2,5 secs.
                        U must keep return a.exec(); to use timers. Its drives the eventloop :)

                        Q Offline
                        Q Offline
                        QtA_
                        wrote on 1 Jan 2017, 17:43 last edited by
                        #11

                        @mrjj said in SplashScreen stay on TaskManager:

                        @QtA_
                        Hi
                        do you now have
                        return a.exec();
                        return a.quit();

                        ?

                        it stays inside a.exec().

                        yes

                        M 1 Reply Last reply 1 Jan 2017, 17:44
                        0
                        • Q QtA_
                          1 Jan 2017, 17:43

                          @mrjj said in SplashScreen stay on TaskManager:

                          @QtA_
                          Hi
                          do you now have
                          return a.exec();
                          return a.quit();

                          ?

                          it stays inside a.exec().

                          yes

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 1 Jan 2017, 17:44 last edited by
                          #12

                          @QtA_
                          You need to send it signal to quit.
                          Try
                          QTimer::singleShot(2500,&app,SLOT(quit()));
                          dont remove the exec() part.
                          its very important to use signals.

                          1 Reply Last reply
                          0
                          • Q Offline
                            Q Offline
                            QtA_
                            wrote on 1 Jan 2017, 17:51 last edited by
                            #13

                            nope,..:( still active.

                            #include <QApplication>
                            #include <QSplashScreen>
                            #include <QTimer>
                            
                            int main(int argc, char *argv[])
                            {
                                QApplication a(argc, argv);
                                QSplashScreen *splash=new QSplashScreen;
                                splash->setPixmap(QPixmap ("C:/Users/public/test/Logo.png"));
                                splash->show();
                                QTimer::singleShot(2500,splash,SLOT(close()));
                                QTimer::singleShot(2500,splash,SLOT(quit()));
                            
                                return a.exec();
                                return a.quit();
                            
                            }
                            
                            M 1 Reply Last reply 1 Jan 2017, 17:58
                            0
                            • Q QtA_
                              1 Jan 2017, 17:51

                              nope,..:( still active.

                              #include <QApplication>
                              #include <QSplashScreen>
                              #include <QTimer>
                              
                              int main(int argc, char *argv[])
                              {
                                  QApplication a(argc, argv);
                                  QSplashScreen *splash=new QSplashScreen;
                                  splash->setPixmap(QPixmap ("C:/Users/public/test/Logo.png"));
                                  splash->show();
                                  QTimer::singleShot(2500,splash,SLOT(close()));
                                  QTimer::singleShot(2500,splash,SLOT(quit()));
                              
                                  return a.exec();
                                  return a.quit();
                              
                              }
                              
                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 1 Jan 2017, 17:58 last edited by mrjj 1 Jan 2017, 18:02
                              #14

                              @QtA_
                              You are asking it wrongly :)

                              QTimer::singleShot(2500,splash,SLOT(quit())); <<<< wrong object. should be &app

                              you are asking the timer to call quit() on splash, which splash dont have.

                              QTimer::singleShot(2500,&app,SLOT(quit()));

                              Update:
                              Also
                              The return statement will make it leave a function
                              so

                              return a.exec();
                              return a.quit(); <<< u can never, ever get here :)

                              1 Reply Last reply
                              0
                              • Q Offline
                                Q Offline
                                QtA_
                                wrote on 1 Jan 2017, 18:05 last edited by
                                #15

                                Thank you very much !! :)
                                so i've added:

                                QTimer::singleShot(2500,&a,SLOT(quit()));
                                

                                and removed

                                return a.exec();
                                

                                seem to work fine now :)

                                Question...

                                why do I need to put time delay on quit if already the time done ?
                                I mean,..

                                QTimer::singleShot(2500,&a,SLOT(quit()));
                                

                                must be

                                QTimer::singleShot(0,&a,SLOT(quit()));
                                

                                ?

                                M 1 Reply Last reply 1 Jan 2017, 18:07
                                0
                                • Q QtA_
                                  1 Jan 2017, 18:05

                                  Thank you very much !! :)
                                  so i've added:

                                  QTimer::singleShot(2500,&a,SLOT(quit()));
                                  

                                  and removed

                                  return a.exec();
                                  

                                  seem to work fine now :)

                                  Question...

                                  why do I need to put time delay on quit if already the time done ?
                                  I mean,..

                                  QTimer::singleShot(2500,&a,SLOT(quit()));
                                  

                                  must be

                                  QTimer::singleShot(0,&a,SLOT(quit()));
                                  

                                  ?

                                  M Offline
                                  M Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on 1 Jan 2017, 18:07 last edited by
                                  #16

                                  @QtA_
                                  Hi
                                  Np.

                                  Does it display long enough with
                                  QTimer::singleShot(0,&a,SLOT(quit())); ?

                                  Then its ok.

                                  1 Reply Last reply
                                  0
                                  • Q Offline
                                    Q Offline
                                    QtA_
                                    wrote on 1 Jan 2017, 18:10 last edited by
                                    #17

                                    ok ...I've change the close by the quit.
                                    instead adding a new line. :)

                                    Thanks again for all your help.
                                    Angie xx

                                    M 1 Reply Last reply 1 Jan 2017, 18:10
                                    0
                                    • Q QtA_
                                      1 Jan 2017, 18:10

                                      ok ...I've change the close by the quit.
                                      instead adding a new line. :)

                                      Thanks again for all your help.
                                      Angie xx

                                      M Offline
                                      M Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on 1 Jan 2017, 18:10 last edited by
                                      #18

                                      @QtA_
                                      Np. Have fun programming. :)

                                      1 Reply Last reply
                                      0
                                      • Chris KawaC Offline
                                        Chris KawaC Offline
                                        Chris Kawa
                                        Lifetime Qt Champion
                                        wrote on 1 Jan 2017, 18:30 last edited by Chris Kawa 1 Jan 2017, 18:40
                                        #19

                                        You don't need to force the app quit. It's not very flexible in the long run. By default Qt app quits automatically when a last window is closed. This is controlled in two places: on application level with setQuitOnLastWindowClosed (the default is true, so no need to change that). The other place is at the widget level with an attribute Qt::WA_QuitOnClose. This attribute is by default enabled for top level windows i.e. widgets with flag Qt::Window or Qt::Dialog except for certain types, including menus, tooltips and splashscreen.

                                        Since a splashscreen is all you have you can just turn the attribute back on:

                                        int main(int argc, char *argv[])
                                        {
                                            QApplication a(argc, argv);
                                            QSplashScreen *splash = new QSplashScreen;
                                            splash->setAttribute(Qt::WA_QuitOnClose);  // <-- the relevant line
                                            splash->setPixmap(QPixmap ("C:/Users/public/test/Logo.png"));
                                            splash->show();
                                            QTimer::singleShot(2500,splash,SLOT(close()));
                                            return a.exec();
                                        }
                                        

                                        Btw. Technically this code leaks memory as you never delete the splash instance. To keep it clean you have couple of options:

                                        • manually delete the splash after the call to exec
                                        • add WA_DeleteOnClose attribute to the splash
                                        • (the easiest and recommended) just create the splash instance on the stack:
                                        QSplashScreen splash;
                                        splash.setAttribute(Qt::WA_QuitOnClose);
                                        splash.setPixmap(QPixmap ("C:/Users/public/test/Logo.png"));
                                        splash.show();
                                        QTimer::singleShot(2500,&splash,SLOT(close()));
                                        
                                        M 1 Reply Last reply 1 Jan 2017, 18:41
                                        2
                                        • Chris KawaC Chris Kawa
                                          1 Jan 2017, 18:30

                                          You don't need to force the app quit. It's not very flexible in the long run. By default Qt app quits automatically when a last window is closed. This is controlled in two places: on application level with setQuitOnLastWindowClosed (the default is true, so no need to change that). The other place is at the widget level with an attribute Qt::WA_QuitOnClose. This attribute is by default enabled for top level windows i.e. widgets with flag Qt::Window or Qt::Dialog except for certain types, including menus, tooltips and splashscreen.

                                          Since a splashscreen is all you have you can just turn the attribute back on:

                                          int main(int argc, char *argv[])
                                          {
                                              QApplication a(argc, argv);
                                              QSplashScreen *splash = new QSplashScreen;
                                              splash->setAttribute(Qt::WA_QuitOnClose);  // <-- the relevant line
                                              splash->setPixmap(QPixmap ("C:/Users/public/test/Logo.png"));
                                              splash->show();
                                              QTimer::singleShot(2500,splash,SLOT(close()));
                                              return a.exec();
                                          }
                                          

                                          Btw. Technically this code leaks memory as you never delete the splash instance. To keep it clean you have couple of options:

                                          • manually delete the splash after the call to exec
                                          • add WA_DeleteOnClose attribute to the splash
                                          • (the easiest and recommended) just create the splash instance on the stack:
                                          QSplashScreen splash;
                                          splash.setAttribute(Qt::WA_QuitOnClose);
                                          splash.setPixmap(QPixmap ("C:/Users/public/test/Logo.png"));
                                          splash.show();
                                          QTimer::singleShot(2500,&splash,SLOT(close()));
                                          
                                          M Offline
                                          M Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on 1 Jan 2017, 18:41 last edited by
                                          #20

                                          @Chris-Kawa
                                          Much better with WA_QuitOnClose, indeed. :)

                                          Do you know if QSplashScreen can do anything special compared to a plain QWidget in terms
                                          of her overall goal? ( sort of fancy launcher )

                                          Im not sure if a custom widget is not more fun later when she wants animations and fade in/out effects etc. Of Course she can derive from QSplashScreen but I do wonder if it
                                          give anything of benefit for this use case. ?

                                          1 Reply Last reply
                                          0

                                          7/29

                                          1 Jan 2017, 17:31

                                          22 unread
                                          • Login

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