Results 1 to 20 of 20

Thread: display QSplashScreen

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default display QSplashScreen

    At the startup of a Qt program, I want to display a QSplashScreen. Maybe it's too fast to get the image. But how can i make the image to last for 2 seconds.
    I'm a greenhand, Thanks!

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: display QSplashScreen

    Hi,
    maybe you can connect a QTimerto a splashscreen slot. But in general you should be happy that your app starts so fast

  3. #3
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display QSplashScreen

    Quote Originally Posted by janus View Post
    Hi,
    maybe you can connect a QTimerto a splashscreen slot. But in general you should be happy that your app starts so fast
    I had looked up the documentation, but i failed to make it. Can you give me an example? Thanks

  4. #4
    Join Date
    Dec 2008
    Posts
    8
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: display QSplashScreen

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. splash->setPixmap(QPixmap(":/images/splash.png"));
    6. splash->show();
    7.  
    8. MyApp mainwindow;
    9.  
    10. QTimer::singleShot(2500, splash, SLOT(close()));
    11. QTimer::singleShot(2500, &mainwindow, SLOT(show()));
    12.  
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display QSplashScreen

    Thanks for your reply.

    But the main problem is that I can't see the image. Even I can make it to delay 2s, but the startup picture didn't turn up.

    What's the problem? Can anyone help? Thanks

  6. #6
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: display QSplashScreen

    Hi,

    hard to guess without code

  7. #7
    Join Date
    Dec 2008
    Posts
    8
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: display QSplashScreen

    Quote Originally Posted by HelloDan View Post
    Thanks for your reply.

    But the main problem is that I can't see the image. Even I can make it to delay 2s, but the startup picture didn't turn up.

    What's the problem? Can anyone help? Thanks
    did you set up a qrc file?

  8. #8
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display QSplashScreen

    Quote Originally Posted by GioFX View Post
    did you set up a qrc file?
    Thanks for your advice.

    Qt Code:
    1. #include <QApplication>
    2. #include <QSplashScreen>
    3. //#include <QThread>
    4. //#include<QTimer>
    5. #include<ctime>
    6. #include "mainwindow.h"
    7. /*
    8. class SleeperThread : public QThread
    9. {
    10. public:
    11. static void msleep(unsigned long msecs)
    12. {
    13. QThread::msleep(msecs);
    14. }
    15. };
    16. */
    17.  
    18. int main(int argc, char *argv[])
    19. {
    20. QApplication app(argc, argv);
    21.  
    22.  
    23. splash->setPixmap(QPixmap(":/images/splash.png"));
    24. splash->show();
    25.  
    26. //splash->showMessage( "Initializing..." );
    27. // app.processEvents();
    28. //......................
    29. MainWindow mainWin;
    30.  
    31. splash->showMessage( "Creating Widgets Page..." );
    32. app.processEvents();
    33.  
    34. splash->showMessage( "Creating Database Page..." );
    35. app.processEvents();
    36.  
    37. splash->showMessage( "Creating Games Page..." );
    38. app.processEvents();
    39.  
    40. // SleeperThread::msleep(2000);
    41.  
    42. time_t t;
    43. t = time(NULL);
    44.  
    45.  
    46. //QTimer::singleShot(2500, splash, SLOT(close()));
    47. //QTimer::singleShot(2500, &mainWin, SLOT(show()));
    48.  
    49.  
    50.  
    51. mainWin.show();
    52.  
    53. while( difftime(time(NULL),t) < 5.0 ) { }
    54.  
    55.  
    56. splash->finish(&mainWin);
    57. delete splash;
    58.  
    59. return app.exec();
    60. }
    To copy to clipboard, switch view to plain text mode 

    This time, I changed my code and alse set up my qrc file. But the program just show a left top rectangle area of the program instead of the image. How can i make image show?
    I will appreciate any reply. Thanks

  9. #9
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: display QSplashScreen

    Hi,

    did you add qrc file to the project file and does it have the correct path prefix?

  10. #10
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display QSplashScreen

    Quote Originally Posted by janus View Post
    Hi,

    did you add qrc file to the project file and does it have the correct path prefix?
    Thanks! In fact I had done all the things. But I found that the following code did make shown the startup images. But the image under the program, So I can't see the startup image. Thanks


    Qt Code:
    1. #include <QApplication>
    2. #include<QTimer>
    3. #include <QSplashScreen>
    4. #include "mainwindow.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9.  
    10. splash->setPixmap(QPixmap(":/images/splash.png"));
    11. splash->show();
    12.  
    13.  
    14.  
    15. MainWindow mainWin;
    16.  
    17. QTimer::singleShot(2500, splash, SLOT(close()));
    18. QTimer::singleShot(2500, &mainWin, SLOT(show()));
    19.  
    20.  
    21. mainWin.show();
    22. return app.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: display QSplashScreen

    You shouldnt be calling mainWin.show() since it will show after timer times out.

    Still you can have the following sequence too -
    Qt Code:
    1. mainWin.show();
    2. splash.show();
    3. QTimer::singleShot(2500, splash, SLOT(close()));
    To copy to clipboard, switch view to plain text mode 
    Hope it works

  12. #12
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: display QSplashScreen

    i dont think mainWin should be shown before the splashscreen..after all, the primary reason of using a splashscreen is to show smth until the main window will show..thus, just removing the mainWin.show should work..also u can have a bit of delay in closing the splash and showing the mainWin..so, if i were u, i'd write

    Qt Code:
    1. MainWindow mainWin;
    2.  
    3. QTimer::singleShot(2500, splash, SLOT(close()));
    4. QTimer::singleShot(2600, &mainWin, SLOT(show()));
    To copy to clipboard, switch view to plain text mode 

  13. The following user says thank you to talk2amulya for this useful post:

    HelloDan (12th February 2009)

  14. #13
    Join Date
    Feb 2009
    Location
    Guangzhou,China
    Posts
    89
    Thanks
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display QSplashScreen

    Quote Originally Posted by aamer4yu View Post
    You shouldnt be calling mainWin.show() since it will show after timer times out.

    Still you can have the following sequence too -
    Qt Code:
    1. mainWin.show();
    2. splash.show();
    3. QTimer::singleShot(2500, splash, SLOT(close()));
    To copy to clipboard, switch view to plain text mode 
    Hope it works
    Thanks. But I just want the splash to show up before the app

Similar Threads

  1. OS/X how to get physical display handle
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2009, 19:51
  2. phonon on a "secondary" display (X11)
    By mnavarro in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2008, 16:38
  3. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  4. QSplashScreen Weirdness
    By mclark in forum Qt Programming
    Replies: 11
    Last Post: 19th November 2007, 06:49
  5. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.