QWidget: Must constuct a QApplication before a QPaintDevice - OpenGL [Solved]



  • Hi all,
    I´ve got always this Debug error (see Title) if I try to add the opengl grabber example (http://doc.qt.nokia.com/4.6/opengl-grabber.html) into my project at work.
    I figured out already that I can solve that issue by using libraries that ends with an "d" but I dont understand why this problem occur?

    First I tried to use the Qt3D Libs (http://labs.qt.nokia.com/2011/09/19/new-qt-quick3d-packages-available/#comment-28205) but there are no "d" libs so I cant use that?

    Maybe you could help me out with that?

    Thanks in advance!!!



  • The error indicates that there is a problem in the order you initialize your classes. You have to initialize a QApplication object before you initialize a widget (or another paint surface, but it usually is a widget that causes the problem). Using the debug libraries (the ones that end in d) may cause a different initialization order, due to optimizations, but using that is not a fix but a workaround that happens to work with your current compiler and compiler version. It would be far better to actually solve the problem, you do not want to have to ship the debug libraries with your actual product and just hope and pray that it will still work with your next release.

    The problem is most likely in your code, not in the Qt example (though bugs there are of course possible as well.)



  • Thx for your reply. So I´ll go on and try to fix it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.