View Full Version : console message
mickey
28th July 2006, 23:00
Hi, after nmake (without warning or erros), I launched my app and immediately appear
a console message:
QPaintDevice: Must construct a QApplication before a QPaintDevice
And app doesn't start. I never see it first.....what happen? thanks...
gfunk
28th July 2006, 23:07
Did you make a QApplication object?
What's your main() function look like?
mickey
28th July 2006, 23:27
my app was working first.......
#include <qapplication.h>
#include <qsplashscreen.h>
#include "mymainform.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
if (!QGLFormat::hasOpenGL())
qFatal("This system has no OpenGL support");
QSplashScreen splash(QPixmap::fromMimeSource("splash.jpg"));
splash.show();
splash.message("Loading ... please wait", 0, QColor(255,255,255) );
a.processEvents();
myMainForm W;
//W.resize(600,500);
a.setMainWidget(&W);
W.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
splash.finish(&W);
return a.exec();
}
wysota
29th July 2006, 00:28
Do you have any global variables which might be using a paint device? Global vars are created before main() is called (thus before QApplication object is created).
mickey
29th July 2006, 13:01
I think it was this below, a variabile of mainform class but initialized as global....
is there a way to do this below without that error? (I'd like prog variabile global; thanks
//mainform.ui.h
myProgressDialog* prog = new myProgressDialog("Saving file...", "Cancel", 0, 1);
void MainForm::init()
{
........
}
wysota
29th July 2006, 14:12
Initialise it after QApplication is created, for example in main().
jacek
29th July 2006, 14:14
is there a way to do this below without that error?
Yes, just initialize it to 0 here and create myProgressDialog after you instantiate QApplication.
I'd like prog variabile global;
Global variables are dangerous.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.