title: background color in Qt and opengl
body: <p>I'm implementing a simple 2D opengl class in qt 4.8 with QtCreator.
  Nothing special, but I'm not able to set the background color oly one when I'm setting up the scene with glOrtho.</p>
  
  <p>here is the code with some commented trials:</p>
  
  <pre><code>#include "glwidget.h"
  #include &lt;iostream&gt;
  
  GLWidget::GLWidget(QWidget *parent) :
      QGLWidget(parent) {}
  
  
  void GLWidget::initializeGL() {
      std::cout &lt;&lt; "GLWidget::initializeGL" &lt;&lt; std::endl;
      glShadeModel(GL_SMOOTH);
      glClearDepth(1.0f);
      glDepthFunc(GL_LEQUAL);
      glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
  }
  
  void GLWidget::resizeGL(int width, int height) {    
      std::cout &lt;&lt; "GLWidget::resizeGL" &lt;&lt; std::endl;
  
      makeCurrent();
  
      glViewport(0,0,(GLint)width, (GLint)height);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluOrtho2D(0, width, 0, height);
  
      glScalef(1, -1, 1);                 // invert Y axis so increasing Y goes down.
      glTranslatef(0, -height, 0);       // shift origin up to upper-left corner.
  
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
      frameCount = 0;
  
      glClearColor(0.0f, 255.0f, 0.0f, 1.0f);
      glClear(GL_COLOR_BUFFER_BIT);
  
      //updateGL();   // this doesn't produce any changes
  }
  
  void GLWidget::paintGL() {
      std::cout &lt;&lt; "GLWidget::paintGL" &lt;&lt; std::endl;
  
      makeCurrent();
  
  //    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // this works but it is in paintGL
  //    glLoadIdentity();
  }
  </code></pre>
  
  <p>the fact is that i want to set the background color only once and all paintGL via updateGL each mouse movement WITHOUT cleaning the background. So the commented lines in the paintGL (that effectivly make the background green) has to keep commented.</p>
  
  <p>For sure there is some update-something to call but I don't understan where.. </p>