What steps are necessary to enable antialiasing when using a QPainter on a QGLWidget?

前端 未结 4 1895
情深已故
情深已故 2020-12-10 03:43

I am trying to draw basic shapes on a QGLWidget. I am trying to enable antialiasing to smooth out the lines, but it is not working.

This is what I am trying at the m

4条回答
  •  醉话见心
    2020-12-10 04:23

    I found the solution. When debugging a different issue, I found messages in my debug output to the effect that you can't set renderhints before the call to begin().

    The following works:

    QGLWidget *widget = ui->renderWidget;
    
    QPainter painter;
    
    widget->makeCurrent();
    glEnable(GL_MULTISAMPLE);
    glEnable(GL_LINE_SMOOTH);
    
    painter.begin(widget);
    
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setRenderHint(QPainter::HighQualityAntialiasing);
    

提交回复
热议问题