Results 1 to 8 of 8

Thread: QSplashScreen question

  1. #1
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QSplashScreen question

    Hi,
    In the following code ...
    Qt Code:
    1. #include <QtGui>
    2. int main(int argc, char *argv[])
    3. {
    4. QApplication app(argc, argv);
    5. QPixmap pixmap("f0.png");
    6. QSplashScreen splash(pixmap);
    7. splash.show();
    8. app.processEvents();
    9. //...
    10. QMainWindow window;
    11. window.show();
    12. splash.finish(&window);
    13. return app.exec();
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 
    ... isn't it expected a mouse click to close the splash screen?

    Or does it mean that i can use the mouse click to close the splash before the QMainWindow finishes loading?

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSplashScreen question

    can you rephrase your question? i cant understand what you want to ask.

  3. #3
    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: QSplashScreen question

    From your code, I guess the splash screen wont be shown.
    Read QSplashScreen::finish. You are calling window.show() and setting finish on the window.
    try showing the window from a timer... say after 2 seconds. and dont call show in the main function itself.

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSplashScreen question

    Quote Originally Posted by aamer4yu View Post
    From your code, I guess the splash screen wont be shown.
    Read QSplashScreen::finish. You are calling window.show() and setting finish on the window.
    try showing the window from a timer... say after 2 seconds. and dont call show in the main function itself.
    but this is the correct way... Qt Assitant shows the same example

  5. #5
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSplashScreen question

    This code close the QSplashScreen when the user clicks on it or when the mainwindow is ready to show
    A camel can go 14 days without drink,
    I can't!!!

  6. #6
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSplashScreen question

    This was my interpretation also.
    But by the way:
    Qt Code:
    1. #include <QtGui>
    2. int main(int argc, char *argv[])
    3. {
    4. QApplication app(argc, argv);
    5. QPixmap pixmap("f0.png");
    6. QSplashScreen splash(pixmap);
    7. splash.show();
    8. //app.processEvents();
    9. //...
    10. QMainWindow window;
    11. window.show();
    12. //splash.finish(&window);
    13. return app.exec();
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 

    Commented this 2 lines and both splash and main windows open at the same time. Click closes the splash.
    Thought this was only possible if using app.processEventes(); !

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSplashScreen question

    Quote Originally Posted by graciano View Post
    This was my interpretation also.
    Thought this was only possible if using app.processEventes(); !
    if you read the docs again.. it says that app.processEvents() is used because app.exe() is not called yet. When your mainwindow is shown, app.exe() is called so no need of processEvents().

  8. #8
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSplashScreen question

    And in this case:
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include <QSplashScreen>
    4. #include <QTimer>
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9. splash->setPixmap(QPixmap("f0.png"));
    10. splash->show();
    11. splash->showMessage(QObject::trUtf8("A preparar a janela principal ..."), Qt::AlignRight|Qt::AlignTop, Qt::black);
    12. MainWindow w;
    13. QTimer::singleShot(5000, splash, SLOT(close()));
    14. QTimer::singleShot(5000, &w, SLOT(show()));
    15. //delete splash;
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 

    Obviously the commented line could not work ... but where to free the used memory by the splash screen?
    Thanks

Similar Threads

  1. licensing question
    By tommy in forum Installation and Deployment
    Replies: 4
    Last Post: 14th April 2010, 11:54
  2. QSplashScreen Weirdness
    By mclark in forum Qt Programming
    Replies: 11
    Last Post: 19th November 2007, 06:49
  3. Replies: 1
    Last Post: 15th March 2007, 20:45
  4. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34

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.