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 not working in Qt Widget Desktop Application
Forum Updated to NodeBB v4.3 + New Features

Splash Screen not working in Qt Widget Desktop Application

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.0k Views 1 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
    vijayzang
    wrote on 3 Apr 2014, 09:10 last edited by
    #1

    Hi There,

    I am trying make a simple splash screen which will show up for a few seconds but when i execute the code,
    Splash Screen appears together with the main window :(
    Below is the code i am using:

    @
    #include <QtGui/QApplication>
    #include <QSplashScreen>
    #include <QTimer>
    #include "mainwindow.h"

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

    QSplashScreen *splash=new QSplashScreen;
    splash->setPixmap(QPixmap("/home/vijayzang/Downloads/ECM_Logo.png"));
    splash->show();
    
    
    
    QTimer::singleShot(2500,splash,SLOT(close()));
    //QTimer::singleShot(2500,&w,SLOT(close()));
    
    MainWindow w;
    
    w.show();
    
    return a.exec(&#41;;
    

    }
    @

    [edit: added missing coding @ tags SGaist]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ankursaxena
      wrote on 3 Apr 2014, 09:17 last edited by
      #2

      So what is your problem ???

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 3 Apr 2014, 10:26 last edited by
        #3

        Hi and welcome to devnet,

        You are calling both show one after the other so the windows will be shown one after the other.

        If you really want to only show MainWindow after a delay you can try something like:

        @
        QSplashScreen splash;
        splash.setPixmap(QPixmap("/home/vijayzang/Downloads/ECM_Logo.png"));
        splash.show();
        MainWindow w;

        QTimer::singleShot(2500,&splash,SLOT(hide()));
        QTimer::singleShot(2500,&w,SLOT(show()));
        return a.exec();
        @

        No pointer needed in this case, otherwise you have a memory leak.

        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
          vijayzang
          wrote on 3 Apr 2014, 11:46 last edited by
          #4

          Thanks for your prompt reply...Will make the changes and check it.

          Cheers :)

          1 Reply Last reply
          0

          2/4

          3 Apr 2014, 09:17

          • Login

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