[Qt-interest] QWidget: Must construct a QApplication before a QPaintDevice

Yifei Li yifli at mtu.edu
Tue Sep 6 16:48:45 CEST 2011


>> 
>> Hi all,
>> 
>> I got this error when running an application (once working with Qt-4.6.2 on
>> Snow Leopard) after I switch to Qt-4.8.0 on Lion.
>> 
>> The error occurs when I construct a QWidget in a plugin loaded by the main
>> application. My application works as follows:
>> 
>> void main(int argc, char* argv[])
>> {
>>     QApplication app(argc, argv);
>> 
>>    // in Core's constructor, plugins are loaded using QPluginLoader
>>     Core core;
>> 
>>    return app.exec();
>> }
>> 
>> Any idea how to solve this? Thanks
> 
> You can do something along the lines of:
> 
> {
>      QApplication app(argc, argv);
>     // plugins are loaded in Core::load()
>     Core core;
>     QTimer::singleShot(0, &core, SLOT(load());
>     return app.exec();
> }
> 
I tried your suggestion, but the problem persists:  QWidget: Must construct a QApplication before a QPaintDevice


I don't understand, there's already a QApplication object 'app' before I load the plugins. How come Qt still complains?

To provide more information: my QMainWidget is constructed in Core's constructor

Any other ideas? Thanks

Yifiei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110906/830f5040/attachment.html 


More information about the Qt-interest-old mailing list