I reimplemented paintGL() :
{
ipainter.
setWindow(QRect(this
->translate.
X,this
->translate.
Y,
1,
1));
ipainter.
setRenderHint(QPainter::Antialiasing,
true);
CanvasDrawer->RunOpenGL(&ipainter);
}
void QGLWidget::paintGL()
{
QPainter ipainter(this);
ipainter.setWindow(QRect(this->translate.X,this->translate.Y,1,1));
ipainter.setRenderHint(QPainter::Antialiasing, true);
CanvasDrawer->RunOpenGL(&ipainter);
}
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:
{
ipainter.
setWindow(QRect(this
->translate.
X,this
->translate.
Y,
1,
1));
ipainter.
setRenderHint(QPainter::Antialiasing,
true);
CanvasDrawer->RunOpenGL(&ipainter);
}
void grCanvas::paintEvent(QPaintEvent* event)
{
QPainter ipainter(this);
ipainter.setWindow(QRect(this->translate.X,this->translate.Y,1,1));
ipainter.setRenderHint(QPainter::Antialiasing, true);
CanvasDrawer->RunOpenGL(&ipainter);
}
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
Bookmarks