Results 1 to 4 of 4

Thread: Using QGraphicsView as a Splash Screen (repaint issues)

  1. #1
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Question Using QGraphicsView as a Splash Screen (repaint issues)

    I've been using QGraphicsView as a splash screen since 4.3. Unfortunately I had to put in some hacks to get it to repaint correctly while the rest of the application was loading. The following code was called any time the status message or progress changed

    Qt Code:
    1. repaint();
    2. QApplication::syncX();
    To copy to clipboard, switch view to plain text mode 
    The weird thing is that this no longer works with Qt 4.4. So I was hoping that someone could help me figure out a sensible way to get my custom splash screen to work. Its just a QDialog with

    Qt Code:
    1. Qt::FramelessWindowHint | Qt::Window
    To copy to clipboard, switch view to plain text mode 
    that has a QGraphicsView as a child widget. My current work around does the trick but I would prefer not to call QApplication::processEvents() even though I'm using

    Qt Code:
    1. QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers
    To copy to clipboard, switch view to plain text mode 
    I tried creating some paint events and sending them over QApplication::postEvent() and QApplication::sendPostedEvents() but I couldnt get that to work either.

    My original plan was to make the Splash Screen a separate process that talked over TCP (in order to get around the repaint issues) but I think engineering an entire system for a splash screen is a bit overkill. Is there anyway to force a graphics view to repaint immediately? Any suggestions?

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

    Default Re: Using QGraphicsView as a Splash Screen (repaint issues)

    Why didn't you use QSplashScreen? A repaint needs a spinning event loop, regardless of what classes you use. TCP also needs a spinning event loop, so unless you start processing events, nothing will get repainted.

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using QGraphicsView as a Splash Screen (repaint issues)

    QGraphicsView as a Splash Screen ,

    Why you not open Gimp/or other Editor draw 4 or 5 PNG image to compose a Animated Portable Network Graphics compress this to one APNG ( save it as resource file like normal image) multiple frame and load it on a QSplashScreen + timer event widged ad show it like a movie...

    To compose APNG image you can use:
    https://addons.mozilla.org/en-US/firefox/addon/5519
    http://www.qt-apps.org/content/show....?content=82221
    http://www.qt-apps.org/content/show....?content=81573
    or commercial
    http://www.gamani.com/apng.htm 30 $


    IMO:
    I forget to propose APNG format on QSplashScreen
    http://trolltech.com/developer/task-...5&method=entry
    i say only QMovie & QWebView ...
    but is simple to read qt code from http://fop-miniscribus.googlecode.co...tiondevice.cpp and run APNG file on QSplashScreen

  4. #4
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default Re: Using QGraphicsView as a Splash Screen (repaint issues)

    A QGraphicsView should be just as good as a QSplashScreen. Using a QGraphicsView allows you to do much more interesting splash screens plus you have control of the layout. For example I've implemented a "progress bar" but it's circular instead of linear. And the status text is comp'd over the bg image instead of below it.

    I suppose it would be possible to use a QSplashScreen along with a QPainter. Essentially all a QSplashScreen is, is a widget with a canned layout, some window flags and a couple of convenience functions. Either way according to the documentation I'll still have the same repaint issues:

    Qt Code:
    1. QPixmap pixmap(":/splash.png");
    2. QSplashScreen *splash = new QSplashScreen(pixmap);
    3. splash->show();
    4.  
    5. ... // Loading some items
    6. splash->showMessage("Loaded modules");
    7.  
    8. qApp->processEvents();
    9.  
    10. ... // Establishing connections
    11. splash->showMessage("Established connections");
    12.  
    13. qApp->processEvents();
    To copy to clipboard, switch view to plain text mode 

    In Qt3 calling repaint caused the widget to repaint immediately. It doesn't seem like the same thing is happening here. It would be better if you could do the following:

    Qt Code:
    1. QPixmap pixmap(":/splash.png");
    2. QSplashScreen *splash = new QSplashScreen(pixmap);
    3. splash->show();
    4.  
    5. ... // Loading some items
    6. splash->showMessage("Loaded modules");
    7.  
    8. splash->repaint();
    9.  
    10. ... // Establishing connections
    11. splash->showMessage("Established connections");
    12.  
    13. splash->repaint();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTimer based Splash Screen
    By bpetty in forum Newbie
    Replies: 6
    Last Post: 15th December 2006, 01:51

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.