PDA

View Full Version : QGLWidget deleted at startup



tksharpless
6th August 2012, 20:53
I regularly use subclasses of QGLWidget as the central widget in a QMainWindow. But now I have one that somehow is getting deleted -- not by my code -- at program startup. The main window ctor creates the widget apparently OK, and it still look OK when its resize handler gets called (as expected) when main() issues show() for main window; but as soon as main calls app.exec() its dtor gets called with a deferred_delete message.

The class in question is an elaboration of one I have used sucessfully in another program, so I guess the problem has to do with something I changed. I'm gradually rolling back those changes but have not yet found the critical one.

But what I want to ask here is the general question: has anyone heard of a QGLWidget deleting itself? Or know why the meta-object or window system might do that?

Thanks, Tom

Added after 16 minutes:

Update: the problem may not be in my QGLwidget subclass, as the identical code still runs OK in the older app. Both main and MainWindow are different in the new app, so that's where I'm looking now.

Added after 11 minutes:

FIXED by moving create/install QGLWidget after GUI setup in MainWindow c'tor. A C++ problem I guess.

But still, who deleted the object, and why?

d_stranz
6th August 2012, 21:54
Why two identical posts? See my reply to the later one: http://www.qtcentre.org/threads/50416-QGLWidget-deleted-at-startup