[Qt-interest] Does QGLWidget have to be manually released?
Joe Liu
passer.by007gg at gmail.com
Thu Oct 15 16:13:22 CEST 2009
Hi guys,
I am writing some OpenGL programs based on QGLWidget;
My program now is quite simple, its structure is generally like this:
===========================================================
*// my Qt gl widget class*
class *MyGLWidget *: public QGLWidget
{
MyGLWidget ();
~MyGLWidget (); // do nothing
// add some additional variables to manipulate the camera
};
*// my main window class*
class *MyWindow *: public QMainWindow
{
MyWindow(QWidget* parent);
~QMainWindow();
MyGLWidget* m_pGLWindow;
}
*// how the GL widget is created and attached to the main window*
MyWindow::MyWindow(QWidget* parent)
: QMainWindow(parent)
{
ui.setupUi(this);
*// set current main window as the parent of the gl widget***
m_pGLWindow = new MyGLWidget (this); **
ui.glLayout->addWidget(m_pGLWindow);
}
==================================================================
At the beginning, everything works well; the GLWidget display a simple quad
in the scene;
However, when i tried to add more variables to help manipulate the camera
states,
The program always crashed when closing the application window;
the compiler outputs the message: Heap block at 013AB9C8 modified at
013ABAE4 past requested size of 114
Anyway, I tried to fix the problem by releasing QGLWidget object manually,
in this way:
==================================================================
MyWindow::~MyWIndow()
{
m_pGLWindow->~MyGLWidget(); *// manually invoke the destructor of GL
widget*
* // delete m_pGLWindow; does not work*
}
==================================================================
Then the program shut down correctly.
So does Qt GL widget have to be manually released? It's very weird...
My Qt: v4.5.2,
OS: Windows XP sp3
Compiler: VC++ 9.0
Need some help, thanks~~
Cheers,
Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091015/82a89547/attachment.html
More information about the Qt-interest-old
mailing list