I reimplemented paintGL() :

Qt Code:
  1. void QGLWidget::paintGL()
  2. {
  3. QPainter ipainter(this);
  4. ipainter.setWindow(QRect(this->translate.X,this->translate.Y,1,1));
  5. ipainter.setRenderHint(QPainter::Antialiasing, true);
  6. CanvasDrawer->RunOpenGL(&ipainter);
  7. }
To copy to clipboard, switch view to plain text mode 

the OpenGL codes are inside the function RunOpenGL .
The widget is black and none of the Opengl drawings is shown.

However, after I changed paintGL() to paintEvent:

Qt Code:
  1. void grCanvas::paintEvent(QPaintEvent* event)
  2. {
  3. QPainter ipainter(this);
  4. ipainter.setWindow(QRect(this->translate.X,this->translate.Y,1,1));
  5. ipainter.setRenderHint(QPainter::Antialiasing, true);
  6. CanvasDrawer->RunOpenGL(&ipainter);
  7. }
To copy to clipboard, switch view to plain text mode 

the drawing result will show on the widget well

What's the problem? why the paintGL doesn't work? It is said to work like paintEvent