PDA

View Full Version : Using QGraphicsView as a Splash Screen (repaint issues)



chezifresh
4th June 2008, 06:19
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


repaint();
QApplication::syncX();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::FramelessWindowHint | Qt::Windowthat 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


QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiersI 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?

wysota
4th June 2008, 07:32
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.

patrik08
4th June 2008, 09:01
QGraphicsView as a Splash Screen :confused:,

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.php/Apng+Video+Frame+Label?content=82221
http://www.qt-apps.org/content/show.php/APNG+Image%2BVideo+format+assembler?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-tracker/index_html?id=212885&method=entry
i say only QMovie & QWebView ...
but is simple to read qt code from http://fop-miniscribus.googlecode.com/svn/trunk/apng_label/src/animationdevice.cpp and run APNG file on QSplashScreen

chezifresh
4th June 2008, 21:22
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 (http://doc.trolltech.com/4.4/qsplashscreen.html) I'll still have the same repaint issues:


QPixmap pixmap(":/splash.png");
QSplashScreen *splash = new QSplashScreen(pixmap);
splash->show();

... // Loading some items
splash->showMessage("Loaded modules");

qApp->processEvents();

... // Establishing connections
splash->showMessage("Established connections");

qApp->processEvents();

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:


QPixmap pixmap(":/splash.png");
QSplashScreen *splash = new QSplashScreen(pixmap);
splash->show();

... // Loading some items
splash->showMessage("Loaded modules");

splash->repaint();

... // Establishing connections
splash->showMessage("Established connections");

splash->repaint();