PDA

View Full Version : probelm in setting the QGLWidget as viewport of QGraphicsView



wagmare
12th October 2012, 07:03
Hi friends,

Im facing a problem of adding a QGLWidget as a viewport of the GraphicsView ...
when i tried to show my QGLWidget it looks perfect ..
but when i tried to add as a QGrraphicsView viewport() im facing a problem...

this is how i added..


QApplication app(argc, argv);

QGraphicsScene *scene = new QGraphicsScene;
scene->setSceneRect(QRectF(0, 0, 1024, 800));

QGraphicsView view;

GLWidget *window = new GLWidget();
window->makeCurrent();
view.setViewport(window);
view.setViewportUpdateMode(QGraphicsView::FullView portUpdate);
view.setScene(scene);
view.show();

the window looks white blank screen.. but when i show GLWidget alone it looks ok.. i drawn a polygon on a balck background QGLWidget ..
please help me ... thanks in advance !

wysota
12th October 2012, 09:14
the window looks white blank screen..
That's what a graphics view viewport is supposed to look like by default since the view clears its background with QPalette::Base.

wagmare
12th October 2012, 10:41
That's what a graphics view viewport is supposed to look like by default since the view clears its background with QPalette::Base.
Wysota!
first thanks for the reply ..
i thought it will set the viewport of QGLWidget with the polygon i drawn on it...
is it possible to show the QGLWidget ..?
QGraphicsProxyItem is the only way..?

wysota
12th October 2012, 10:44
You can use drawBackground() to execute your OpenGL code or you can probably prevent the view from clearing the background.