opengl widget not able to embed in QGraphicsView
Hi friends,
i tried to embed a QOpenGL widget to my QGraphicsView using QGraphicsProxyWidget .. i tried
adding the widget like this ..
Code:
QGraphicsProxyWidget *proxy = scene->addWidget(glWidget);
but it returns warning as
Quote:
QPainter::begin: A paint device can only be painted by one painter at a time.
and it not showing the widget ...
when i replace the opengl widget with normal widget (QTextEdit) it renders it properly ..
my openGL paintGL() code is..
Code:
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
glOrtho(this->max_x,this->max_y,this->min_x,this->min_y,-1.0f,1.0f);
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, texture);
glBegin (GL_TRIANGLE_STRIP);
....
....
glEnd ();
glPopMatrix();
please help me in solving this issue ... where it requires painter.save() function ..? or some other ..? in QGLWidget where i have to use Qt GL functions ..?
please help me ... thanks in advance ..
Re: opengl widget not able to embed in QGraphicsView
Well, in the QGraphicsScene::addWidget documentation its clearly stated:
Quote:
Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller are not supported. Examples are QGLWidget and QAxWidget.
Quote:
in QGLWidget where i have to use Qt GL functions ..?
What do you mean ? You dont know where to put your OpenGL code ? Again, have you read the docs ? http://doc.qt.nokia.com/stable/qglwidget.html
Re: opengl widget not able to embed in QGraphicsView
Quote:
in QGLWidget where i have to use Qt GL functions ..?
sorry instead of using QPainter i had written Qt GL functions ...
Quote:
Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller are not supported. Examples are QGLWidget and QAxWidget.
fine ... stampede ... can u tell me is there any other option to embed a OpenGL widget ..?
i got this reference http://www.qtcentre.org/threads/1230...sScene-problem
Re: opengl widget not able to embed in QGraphicsView
Quote:
can u tell me is there any other option to embed a OpenGL widget ..?
Honestly, I dont know. Docs says that its not supported, but in the thread you've linked seems to be some kind of workaround for this. There is a code sample as well.
Just try the suggestions posted there and see how it goes.
Re: opengl widget not able to embed in QGraphicsView
thanks for reply ... stampede ..
in that thread they are just adding that widget as seperate viewport not as QGraphicsItem ... ok i see is there any other way ..
and once again thanks for reply ..