Solved QWidget: Must construct a QApplication before a QWidget
-
Hello, I'm trying to run a QVTKOpenGLWidget in Qt5.9.2 and I'm using Visual Studio 2015 with Qt plugin. I have added folder with dll files to enviromental variable PATH and when program runs, I'm getting this error:
QWidget: Must construct a QApplication before a QWidget
Unhandled exception at 0x763F543B (ucrtbase.dll) in hello_test3.exe: Fatal program exit requested.How to deal with this?
-
How is your main.cpp looking like?
-
#include "hello_test3.h"
#include <QtWidgets/QApplication>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
hello_test3 w;
w.show();
return a.exec();
} -
@michalt38 is it possible you're mixing libraries in debug and release mode ? See this answer from stackoverflow as it might apply to your environment.
-
@michalt38 Do you have any static variables?
-
@jsulm no, I don't
-
@michalt38 said in QWidget: Must construct a QApplication before a QWidget:
hello_test3.h
Can you show the content of
hello_test3.h
andhello_test3.cpp
(if it exists)? -
Are you creating any widget object in the global scope ? Either in some header file or somewhere else ?
-
This problem was beacouse I mixed debug and release libraries
-
@michalt38 so if your problem is solved now, please don't forget to mark your post as such.