PDA

View Full Version : Add widget on top of existing QGLWidget



scarecr0w132
6th December 2013, 00:18
Hello,

I am trying to add widgets on top of an existing QGLWidget.
I have followed this (http://doc.qt.digia.com/qq/qq26-openglcanvas.html) and trying to implement it into my code.
Here is some code:



...
// occView derives QGLWidget
myOccView = new occView(myContext, this);
GraphicsView* view = new GraphicsView();
view->setViewport(myOccView);
view->setViewportUpdateMode(QGraphicsView::FullViewportU pdate);
view->setScene(new OpenGLScene);
view->show();
view->resize(1024, 768);
view->raise();
...


It opens the normal QGLWidget, and also opens in a seperate window the graphics view.

But then programme crashes at view->setViewport(myOccView);
http://postimg.org/image/wl7fd315t/
and says:

QWindowsGLContext::makeCurrent: SetPixelFormat() failed (The pixel format is invalid.)
ASSERT: "context" in file opengl\qopenglfunctions.cpp, line 194 (https://qt.gitorious.org/qt/qtbase/source/65755f9a68947e774c640ce92c022d677acdcc4a:src/gui/opengl/qopenglfunctions.cpp#L194)
qwidget::repaint: recursive repaint detected

If I remove:
view->setViewport(myOccView);
It doesn't crash and opens the two windows :
http://postimg.org/image/ewmy1uarb/

So I am wondering how I attach the graphicsView to my QGLWidget. I think this will solve the crash.

Thank you.