Better try creating that painter on the stack every time you need it.
Better try creating that painter on the stack every time you need it.
mmm but I need it fixed displayed on myWidgetGL....
Regards
Just create the painter on the stack in the method which uses it, this way it will be destroyed in the right time and you won't have to bother with QPainter::end().
Sorry, but how do I create painter on the stack?? But the problem of have fixed rect on my QGLWidget persist....
Thanks
Regards
Qt Code:
painter.drawRect(10,10,50,50);To copy to clipboard, switch view to plain text mode
sorry but I tried also this (I insert in paintGL() ) but the rect isn't appear; apper only while I traslate/rotate my scene (when updateGL()); maybe is there something that delete it?mmm; (ok for problem of painter.end()). Thanks
Regards
Then try:Qt Code:
{ painter.drawRect(10,10,50,50); }To copy to clipboard, switch view to plain text mode
with your code console ask me this: 'painter.begin(this);' adding this istruction seems works , but when I traslate /rotating my scene square disappear (calls to updateGL() ); strange: if I click on my scene (updateGL occurs) rect appear; I see that If I moveMouse with buttonMouse down paintEvent() not occurs; instead If I click only, paintEvent occur();
Furthermore I have QWidget::mouseLeave() where inside there's an updateGL(): when I mouse mouse out, updateGL occurs and rect disappear!
mmmmm....
Regards
It looks like QGLWidget repaints are handled in a special way. You might try rendering your scene to a pixmap, painting on that pixmap and then displaying it, but this will affect the performance.
Bookmarks