tonnot
tonnot

Reputation: 455

Qt QGraphicsScene & OpenGL, which can be the best approach to mix both?

I'm going to start development on my vectorial viewer app. I have explored the 2D and 3D Qt tools and I have the impression that I have to create two independents data worlds. The QGrapchicsScene needs 'items', the OpenGL needs raw data. What is your opinion ?

Upvotes: 2

Views: 1880

Answers (1)

Michael Daum
Michael Daum

Reputation: 830

Only way I've seen to do this is to use the paradigm layed out in the "Boxes" demo accessible from the qtdemo executable which is included with Qt.

Basically you must subclass QGraphicsScene and place all of your openGL code into your subclass's overridden version of the virtual drawBackground() function. Then you place a QGraphicsView (or subclass thereof) in your UI, and use QGraphicsView::setViewPort(QWidget *) to put a QGLWidget in as the graphics view's viewport, which will allow your drawBackground code to use openGL.

Upvotes: 2

Related Questions