[Qt-interest] QWidget: Must construct a QApplication before a QPaintDevice
Samuel Rødal
samuel.rodal at nokia.com
Tue Sep 6 17:19:13 CEST 2011
On 09/06/2011 04:48 PM, ext Yifei Li wrote:
>
>>>
>>> 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
Are you sure your application doesn't contain static initialized data
that uses QWidget?
--
Samuel
More information about the Qt-interest-old
mailing list