PDA

View Full Version : QCoreApplication - startingUp()



googie
30th September 2009, 08:12
Hi,

I'm not entirely sure if I can use Qt classes before QCoreApplication app; app.exec(). I met once app.argument() to cause segmentation fault, I don't know why :( I'm not even able to check if I already can do anything with Qt objects.

I'm playing with startingUp() static method from QCoreApplication. As far as I understeand it from documentation - it should return true while application is starting up and some more objects needs to be initialized (etc, etc, ...), but whould return false when application (the Qt) is ready for regular processing.

For me it always returns true (until application quit). As I read in Qt sources - it's set to true at start and to false at shutting down.

Is it really as I read in sources, or did I miss something? ...and what about usage of Qt classes (except QEvent, of course) before exec()?

wysota
30th September 2009, 08:21
You can use any classes you want as long as they are not paint devices (QPixmap, QWidget). You can use those as well before QApplication::exec() but only after creating the application object. Also the constructor of QCoreApplication is responsible for loading Qt plugins so SQL and image classes are fully available only after the application object has been created.

googie
30th September 2009, 08:24
Thanks for quick response!

And what about startingUp() in QCoreApplication? Now I took closer look at QApplication and QCoreApplication sources and it appears that QApplication sets this property correctly, but QCoreApplication will always return true.

I'll drop usage of this method, but I'm just curious.

wysota
30th September 2009, 08:43
For QApplication it will return false once QApplicationPrivate::initialize() is called happens from the application constructor.