PDA

View Full Version : Automatic start routine after GUI started



enno
31st May 2010, 11:29
My program has a lengthy initialization routine. If I call the routine before the app.exec() there is a long wait before the main window appears which I would like to avoid.

How can I get the window showing first and then the initialization routine started without user involvement?

I may have to intercept QEvent::ApplicationActivate or something event like that ???

Appreciate any help
Enno

tbscope
31st May 2010, 11:32
A single shot timer set to a low value in your constructor.
When the timer is finished, start your initialisation.

At least that's how it's done in KDE if I remember it correctly, but it has been a while.

high_flyer
31st May 2010, 11:37
it depends.
If your main window needs data initialized before then either show it, and update the data when it is initialized or, the more "standard" way, is to show a splash screen, and some sort of information about the initialization process, so that the user knows he has to wait a bit. (See GIMP as one example).

wysota
31st May 2010, 14:22
Use QMetaObject::invokeMethod() with Qt::QueuedConnection.