Important: Please read the Qt Code of Conduct -

OpenGL multisampling not working when QOpenGLWidget is used in third party Qt application

  • I'm trying to implement a widget in a third party Qt application.

    The widget is used to display CAD drawings converted to .svg (scalable vector graphics). The drawings are rather complex and that's why OpenGL acceleration is desired. However, there is an issue with multisampling not working/is disabled, meaning the CAD drawings look really bad. The constructor of the widget is shown below:

    MyWidget::MyWidget(QWidget *parent)
    : QGraphicsView(parent)
        //Create a new scene, set various attributes
        setScene(new QGraphicsScene(this));
        //Set the viewport as an OpenGL widget for GPU acceleration
        QSurfaceFormat format;
        QOpenGLWidget *gl = new QOpenGLWidget();
    void MyWidget::paintEvent(QPaintEvent *event)
    void MyWidget::initViewport()
        //Get the scene pointer
        QGraphicsScene *s = scene();
        //Set the background color to white
        //Create a new .svg item
        QSvgRenderer *renderer = new QSvgRenderer(this->svgPath);
        drawingItem = new QGraphicsSvgItem();
        //Set the boundary for the scene

    As shown in the code above I set 4 samples per pixels, however this seems to be completely ignored. It doesn't matter what number I put there, it renders without multisampling. I talked with the support team of the third party application and they say there's nothing on their end that can cause it.

    Does any OpenGL/Qt experts here have any insights/ideas on what may cause the rendering to ignore multisampling? If not in this case, just in general?

    Let's say it actually is the third party Qt app that causes it, what can potentially be in their code that screws with my widget? They say there's no OpenGL stuff going on their end.

    Any smart ways to figure out what's happening behind the scenes?

    Important additional information:

    • The third party app runs on Windows 64 bit.

    • When I use the exact same initialization code (as in the constructor) in a stand-alone Qt app I made, multisampling works without issues. (Which should mean this is not a hardware issue).

    • When I compile the exact same source code for an ARM device (they've made an Android app for their UI), multisampling works without issues. (Not very applicable because it's a different platform and OpenGL ES, but maybe still worth noting)

    • This code is based on the svgViewer from here
      Qt 5.5 from binaries is used.

    • I use no native OpenGL calls in the code, i.e. paintGL() is never called/implemented explicitly by me.

    If you need more information, please ask :)

    Thank you all in advance!

Log in to reply