In my application I have a openGL window that I have added to a QGridLayout as a widget and this QGridLayout is set as a layout for a QFrame. On run-time I need to remove this OpenGL window from the QFrame and show it separately from main window by right clicking on it. and the reveres ; I need to add it back to the QFrame as a widget of a QGridLayout.
this is just a part of test code to see if I can add the OpenGL widget to the layout and remove it afterwards and show it on a separate window:
QGridLayout* layout = new QGridLayout;
m_canvas = new CanvasRender(0, layout); // OpenGL context
layout->addWidget(m_canvas, 6, 1);
if I call this line @layout->removeWidget(m_canvas); @ exactly after adding the widget to layout then it works fine. otherwise the openGL window (which is inherited from QGLWidget) is separated from layout but not the Qframe and it sticks to the frame and you can't move it around. I have search a lot but couldn't find a solution. I will be glad for any help! :)
If I'm not mistaken, your CanvasRender is still parented to your QFrame, set it's parent to 0 after removing it and you should be able to move it around.
Thanks! yeah that was the problem and now it's fixed!
Since it's all good, don't forget to update the thread's title to solved so other forum users may know a solution has been found :)