Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt 4.8.6 VS2010 only works in Release Mode, needs QApplication before QPaintDevice for QWidget
dbalgley last edited by
Hello Qt Qomrades,
Let me spin you a tale about the developer who tried to play God.
I'm working on a project that requires use of some plotting functionality, and figured Qt and QCustomPlot would be a great addition. I worked on creating a "Qt Patch" that would only include the files needed for basic functionality of Qt and, moreover, exactly what QCustomPlot needed to operate-as the project already includes a wrapped version of Qt to push GUI. After some trial and error, consternation, and more than my fair share of swearing, I got to the point where my console would display the error:
@QWidget: Must construct a QApplication before a QPaintDevice@
while in Debug mode. On a whim (and after several days of that error message haunting my dreams) I flipped over to Release mode and glory glory hallelujah it compiled, ran, and showed me a plot. Like an idiot, I took this as the Deus Ex Machina it seemed like it was and pushed forward with my project. But now the dark times are upon me again-and I need NEED debug functionality.
Here's my process:
1.) Develop the code in QtCreator. Get the graph working there.
2.) Take the functionality that allowed for my graph logic and render from QtC and move it into VS2010, aka my project. Move the moc_qcustomplot.cpp file as well. No ui_, .pro, or anything else come with, as the UI and such are handled locally, and I don't ever need to rebuild qcustomplot.cpp/.h
3.) Render the graph, using the wrappers from my project:
@Wrapper::Widget *pWidget = new Wrapper::Widget(this);
/The below is part of my project's libraries, which returns a QWidget from its own Widget object/
QWidget *pWid = new QWidget(pWidget->GetQWidget());
customplot = new QCustomPlot(pWid);
//Fiddly bits that use customplot to render my magnificent graphs@
In release, this works. In debug, I get the aforementioned error. My true question is-are there qXXX_debug.h files somewhere? Am I missing something from my "QTPatch" file? Included is some relevant (and basically all of my) QT code inside my project as well as the list of my "QTPatch" included files, both .h and .lib files. I am unable to create a "new" qt project using the VSplugin or anything of the sort, and this has to be within the confines of my project's existing structure.
Any help would be greatly appreciated and if you can get me set on the right path I will forever inscribe your name on the wall of my heart of hearts, as well as shout it from the rooftops and probably name a variable after you. A really important one. Perhaps a vector.
THANK YOU IN ADVANCE!!!
@INCLUDES FOR QTPATCH
/QTPatch means that I cut these out of Qt/4.8.6/src(or gui), and then put them in a new file in my project and redid the dependencies so they linked to each other properly. this was done for QCustomPlot functionality./