View Full Version : [qt4,win,g++] QPainter on a QGLWidget

3rd February 2006, 20:06

to draw a rubberband on a opengl widget for selection
i want to draw a rectangle
using qpainter in xor mode. when the painter starts painting
the gl widget disapears suddenly and only the rectangle is shown. after
the painter stops painting the gl widget shows up again.

how can i draw on a OpenGL widget using qpainter? the same code
worked in qt3 ?!

(qrubberband does not work in this case because it's much too slow since
the opengl widget is repainted every time the size of the rubberband is changed)

best regards,

4th February 2006, 12:14
Wouldn't it be better to draw the band using OpenGL?

4th February 2006, 12:45
would be nice if it works with qpainter as well. especially
if it works with qt3 and one of the improvements of qt4 is
that you can use qpainter with opengl (?!).
btw, i suppose the problem is about painting on a widget
outside a paintevent (s.a. my other posting) if i get a solution
for that i guess i have a solution for the opengl problem, too.


25th July 2008, 15:38
Hello All.
Currently I have interest for solution of the same problem.
I try to realize custom RubbertBand for OpenGL view on QWidget.

Implemetation Rectangle Rubber Band - not a problem( QRegion supports rectangles -> QWidget::setMask -> good perfomance ) It is aproach from Qt original sources.
But problem exists with Non-rectangular figures (slanting lines, for example)
Surrounding of lines by QRegions (constructed from QPolygon ) leads to Blinking of OpenGl viewer.
(NB. horizontal and vertical lines are not blinking! only slanting lines)

Creating mask from QPixmap ( I try to draw Rubber Band contur by QPainter on QPixmap ) lead to very slow performans.

Any ideas?

Thanks in advance,

PS. Qt version - 4.3.3
PPS. Drawing RubberBand in OpenGL Viewer is impossible for me, because I have two or more kind of different based on OpenGl viewers.

28th July 2008, 07:29
On WindowsXP all is ok(even on Intel Graphic card), but under Mandriva 2006 still blinking.
May be problem is too old video drivers?