Results 1 to 10 of 10

Thread: Problem with Splash Screen ?

  1. #1
    Join Date
    Mar 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Problem with Splash Screen ?

    Hello,

    Here is my code. I am trying to display the "Logo" image as a splash screen on top all of my windows. But when executing , the splash screen is displayed on bottom of the main widget. What is the reason ? How can I solve it ?

    Qt Code:
    1. #include <qapplication.h>
    2. #include "welform.h"
    3. #include <qtimer.h>
    4. #include <qpixmap.h>
    5. #include <qsplashscreen.h>
    6.  
    7.  
    8. int main( int argc, char ** argv )
    9. {
    10.  
    11.  
    12. QSplashScreen *splash=NULL;
    13. QApplication a( argc, argv );
    14. welForm *w;
    15.  
    16.  
    17. QPixmap logo(QPixmap::fromMimeSource("Logo"));
    18. splash=new QSplashScreen(logo,Qt::WStyle_StaysOnTop|Qt::WX11BypassWM);
    19. splash->show();
    20. QTimer::singleShot(5*1000,splash,SLOT(close()));
    21.  
    22. w=new welForm(0,"welForm");
    23. a.setMainWidget(w);
    24. w->show();
    25.  
    26. //delete splash;
    27. //a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    28. int rc=a.exec();
    29.  
    30. //splash->finish(w); this finish() also not work.... so I commented it.
    31. if(splash)
    32. delete splash;
    33.  
    34. return rc;
    35. }
    To copy to clipboard, switch view to plain text mode 


    thanks in advance............

    A S Vinod
    Last edited by wysota; 7th March 2007 at 11:01. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,355
    Thanks
    3
    Thanked 5,009 Times in 4,788 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Problem with Splash Screen ?

    Try this:
    Qt Code:
    1. QApplication app(argc, argv);
    2. QSplashScreen *splashscreen = new QSplashScreen(QPixmap::fromMimeSource("Logo"), Qt::WDestructiveClose|Qt::WStyle_StaysOnTop); // no need for other flags
    3. splashscreen->show();
    4. app.processEvents(); // this should make the splash appear
    5. welForm *w = new welForm(0,"welForm");
    6. app.setMainWidget(w);
    7. w->show();
    8. QTimer::singleShot(5000,splashscreen,SLOT(close())); // timer needs the event queue
    9. return app.exec();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Problem with Splash Screen ?

    Hello,

    I had tried your code. But the result was same. The splash screen always appeared below to the main window.


    So what will be he exact problem....


    Vinod

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,355
    Thanks
    3
    Thanked 5,009 Times in 4,788 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Problem with Splash Screen ?

    Did you pass any window flags to the main window?

  5. #5
    Join Date
    Mar 2006
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Problem with Splash Screen ?

    No , I didn't pass any arguments to main window...

    But , now I solve the problem.

    By just calling the finish(mainWindow) function of SplashScreen class before calling show(mainWindow).

    Here is the working code :-

    Qt Code:
    1. int main( int argc, char ** argv )
    2. {
    3.  
    4. QApplication a( argc, argv );
    5.  
    6.  
    7. QSplashScreen *splash=new
    8. QSplashScreen(QPixmap::fromMimeSource("Logo"),Qt::WDestructiveClose|Qt::WStyle_StaysOnTop);
    9. splash->show();
    10. a.processEvents();
    11. welForm *w=new welForm(0,"welForm");
    12. a.setMainWidget(w);
    13. splash->finish(w);
    14. w->show();
    15.  
    16. QTimer::singleShot(10000,splash,SLOT(close()));
    17. return a.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 



    Thank You...
    Last edited by wysota; 7th March 2007 at 11:00. Reason: missing [code] tags

  6. #6
    Join Date
    Apr 2006
    Posts
    5
    Thanks
    1
    Platforms
    Unix/X11 Windows

    Default Re: Problem with Splash Screen ?

    hello...
    i am trying to display a splash screen before my application starts. But it is not displaying SplashScreen. given below is my code.

    Qt Code:
    1. #include <QApplication>
    2.  
    3. #include "client.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8. QPixmap pixmap("redcross.png");
    9. QSplashScreen *splash = new QSplashScreen(pixmap);
    10. splash->show();
    11. app.processEvents();
    12. splash->showMessage("Loaded modules");
    13.  
    14. client client;//inherited from QDialog
    15. splash->finish(&client);
    16. client.show();
    17.  
    18. QTimer::singleShot(5000,splash,SLOT(close())); // timer needs the event queue
    19.  
    20. return app.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

    thanx
    Last edited by wysota; 7th March 2007 at 10:45. Reason: missing [code] tags

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,355
    Thanks
    3
    Thanked 5,009 Times in 4,788 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: Problem with Splash Screen ?

    I tested the code and it worked for me. Maybe the problem is that you use a relative path to the redcross.png image? If QSplashScreen can't find it, it won't be displayed.

  8. The following user says thank you to wysota for this useful post:

    yabadabadoo (7th March 2007)

  9. #8
    Join Date
    Apr 2006
    Posts
    5
    Thanks
    1
    Platforms
    Unix/X11 Windows

    Smile Re: Problem with Splash Screen ?

    yes.... that was the problem... thank you very much..

  10. #9
    Join Date
    Jan 2019
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Problem with Splash Screen ?

    can i use finish before calling show() on the mainwindow?

  11. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,134
    Thanks
    35
    Thanked 1,477 Times in 1,430 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Problem with Splash Screen ?

    Quote Originally Posted by Prashant Kumar View Post
    can i use finish before calling show() on the mainwindow?
    That is what the code in post #6 does, isn't it?.

    Cheers,
    _

Similar Threads

  1. Splash screen showing for two seconds
    By Koas in forum Qt Programming
    Replies: 5
    Last Post: 17th October 2008, 20:40
  2. Using QGraphicsView as a Splash Screen (repaint issues)
    By chezifresh in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2008, 22:22
  3. QTimer based Splash Screen
    By bpetty in forum Newbie
    Replies: 6
    Last Post: 15th December 2006, 01:51
  4. Replies: 3
    Last Post: 8th December 2006, 19:51
  5. Problem with screen update...
    By mysearch05 in forum Qt Programming
    Replies: 2
    Last Post: 27th January 2006, 19:24

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.