PDA

View Full Version : why"QPixmap: Must construct a Qapplication before a QpaintDevice" only in Debug mode?



richardander
8th January 2009, 10:13
Hello,

I upgraded my application from Qt3.3 to Qt4.4. I have the following problem when the Qt4.4 program is running.

- In release mode, it works fine;;

- In debug mode, compilation and link is ok. However, when it runs, it pops up a error message:

QPixmap: Must construct a Qapplication before a QpaintDevice.

Following is the code in my main program and the error happened at :
MainWindow smw;

But I create QApplication before it already!

- also, the release version can work ...

Can anyone help me why this happened and how to solve it?

thank you very much!





int main( int argc, char ** argv )
{
try
{

QApplication app( argc, argv );

MainWindow smw;
app.setMainWidget( &smw );
smw.hide();

...
}
...
}

jpn
8th January 2009, 13:36
Probably there's a debug vs. release mismatch. Do you have some library that is compiled in release mode? That would explain why your application works in release mode but not in debug mode. Once you compile your application in debug mode, you should link against the debug version of that library.