[Qt-interest] disappearing widgets in QGraphicsScene
Samuel Rødal
sroedal at trolltech.com
Tue Nov 10 12:42:51 CET 2009
Yifei Li wrote:
> Hi,
>
> I kinda fixed the problem by saving and then restoring modelview and projection matrices.
>
> However, the problem still persists when I enable multiple viewports. I tried glPushAttrib/glPopAttrib, but that did not help.
>
> Here is what I tried:
>
> void drawBackground(QPainter*, const QRectF&)
> {
> glClearColor(...)
> glClear(...); // clear depth and color buffer
>
> glPushAttrib(GL_ALL_ATTRIB_BITS);
> glMatrixMode(GL_PROJECTION);
> glPushMatrix();
> glMatrixMode(GL_MODELVIEW);
> glPushMatrix();
>
> // render stuff in the 1st viewport
> ...
> // render stuff in the 2nd viewport
> ...
>
> glMatrixMode(GL_PROJECTION);
> glPopMatrix();
> glMatrixMode(GL_MODELVIEW);
> glPopMatrix();
> glPopAttrib();
> }
>
> Please help me out. Thanks
>
> Yifei
If you're using Qt 4.6 you can try surrounding the OpenGL code with
painter->beginNativePainting() and painter->endNativePainting(). That
should lead to better synchronization when intermixing QPainter and raw
OpenGL code (even if you don't use the QPainter in drawBackground it's
used by QGraphicsView).
--
Samuel
More information about the Qt-interest-old
mailing list