i have problem with overpainting in qglwidget, when i create QPainter p(this) in paintG,L swapbuffers() dont work and my widget blinked during animation using updateGL and give me this error:
QOpenGlContext::swapBuffers called without corresponding makecurrent()
and when i using paintEvent() and i use update() i havent see smooth swap buffer too but if i dont use QPainter its work so good,

How can i use QPainter beside using swapbuffers()? do we have any function fer getting current context painter device?

this is my code
Qt Code:
  1. paintGL()
  2. {
  3. glClearColor(0,0,0,1);
  4. glClear(GL_COLOR_BUFFER_BIT);
  6. QPainter p(this);
  7. drawBackground(&p);
  8. drawForeground();
  9. }
To copy to clipboard, switch view to plain text mode 

sorry for bad english and thanks.