[Qt-interest] Does QGLWidget have to be manually released?
Joe Liu
passer.by007gg at gmail.com
Fri Oct 16 04:51:11 CEST 2009
Ok, I've made a mistake somewhere else;
My fault, Not the problem of Qt GL;
Sorry for that~~
2009/10/16 Joe Liu <passer.by007gg at gmail.com>
>
>
> 2009/10/15 Donal O'Connor <donaloconnor at gmail.com>
>
>> Does you're sub class pass the parent widget pointer to the QGLWidget
>> superclass, QGLWidget?
>>
>> *//// Yes, MyGLWidget pass the parent window pointer to the QGLWidget in
> its constructor;
> *
>
>
>> Also, you don't have a constructor in your MyGLWidget that accepts a
>> pointer to a QWidget, not sure how it even compiles that way unless I'm
>> missing something.
>>
>
> *//// it's a typing error; of course I have such a constructor which
> accepts a pointer to the parent window; I just followed the sample code in
> Hello GL coming with Qt. *
>
>>
>>
>> On Thu, Oct 15, 2009 at 3:13 PM, Joe Liu <passer.by007gg at gmail.com>wrote:
>>
>>> 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
>>>
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091016/1f63be34/attachment.html
More information about the Qt-interest-old
mailing list