How to enable multisampling Anti-Aliasing with QOpenGLWidget?

  • I have a QDockWidget that contains a QOpenGLWidget inside it.
    I'm trying to set up AA in the GL viewport, but nothing I tried so far worked.

    Right now I'm trying to set up the surface format in the widget's constructor, like so:

    QSurfaceFormat format;
    format.setVersion(4, 1);	

    Then, in the initializeGL function, I've added the line glEnable(GL_MULTISAMPLE);
    However, it doesn't work. No Anti-Aliasing.
    I tried several other approaches, including creating the GL context myself and setting the format on it or setting up application flags and the default surface format, but none of them worked either.

    I'm quite at a loss here, and I'm probably missing something simple since the consensus points to format.setSamples(16); as the crucial element, but as I said, it doesn't work for me.

    Any ideas what I'm doing wrong here?

Log in to reply