Results 1 to 4 of 4

Thread: Animating QSplashScreen

  1. #1
    Join Date
    Oct 2010
    Posts
    41
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Animating QSplashScreen

    Hi,

    I'm trying to animate QSplashScreen to show that it's not blocked, most of the loading time is spent in the MainWindow constructor, specifically creating 2 instances of Phonon::VideoWidget. I have subclassed QSplashScreen and reimplemented drawContents(). On the splash screen I want to show a simple moving gradient but I'd be happy to just show a few blinking dots as in "Loading...".

    I'm using timers and slots to animate it, these must be in an event loop but before the MainWindow is created I can't use the QApplication's event loop, so one option would be to use a local QEventLoop but this doesn't make much sense because it would have to be before the call to the MainWindow constructor, which would stop this constructor from being called until the local event loop is finished.

    Calling qApp->processEvents() several times around the code is not an option because the operations that take the longest during startup are only 2 VideoWidget constructors, the time taken by the rest is almost negligible. I've tried with a QThread with the highest priority but I think the priority is ignored and the timeout() signals aren't processed while the VideoWidget objects are being created in the MainWindow constructor which makes the animation bumpy.

    I've almost given up hope that splash screens can be animated succesfully in Qt but I decided to ask here.

    Thanks in advance.

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Animating QSplashScreen

    There is nothing that you can do as far as I know... Would you like to have a splashScreen being a separated app? then you can use QSharedMemory to handle its state...
    Don't write a post just to thank someone, use "Thanks" button.

  3. #3
    Join Date
    Oct 2009
    Posts
    483
    Thanked 96 Times in 93 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Animating QSplashScreen

    It is likely nothing can be done to solve your problem because:
    1) all the GUI work must be done in the same thread, which means that the VideoWidget constructor will freeze the rest of the GUI;
    2) having the event loop running will not help unless the VideoWidget constructor itself calls e.g. qApp->processEvents().

    On a side note, it is in general a bad idea to do some heavy work in the constructor of the main window. You should instead move the time-consuming code to a private slot initialize() and schedule its execution as soon as event processing starts by adding, for instance, the following line to the window's constructor:
    Qt Code:
    1. QTimer::singleShot(0, this, SLOT(initialize()));
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Oct 2010
    Posts
    41
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Animating QSplashScreen

    hen you can use QSharedMemory to handle its state
    That's a good idea.

    On a side note, it is in general a bad idea to do some heavy work in the constructor of the main window. You should instead move the time-consuming code to a private slot initialize() and schedule its execution as soon as event processing starts by adding, for instance, the following line to the window's constructor:
    Thanks, I wasn't aware of this.

Similar Threads

  1. Widget for Animating a Series of Images
    By cpsmusic in forum Newbie
    Replies: 7
    Last Post: 30th June 2010, 06:44
  2. Animating many items in a QGraphicsScene
    By Luc4 in forum Qt Programming
    Replies: 6
    Last Post: 5th May 2010, 06:55
  3. Animating QDockWidget
    By vajindarladdad in forum Newbie
    Replies: 1
    Last Post: 15th December 2008, 08:02
  4. Animating QDockWidget
    By vajindarladdad in forum Qt Programming
    Replies: 0
    Last Post: 11th December 2008, 10:16
  5. animating a toolbar??!?
    By nupul in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2006, 08:27

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.