Important: Please read the Qt Code of Conduct -

Using QOpenGLWindow on Mac

  • Hi all,

    we are using Qt in a project with OpenGL context. We specify OpenGL compatability as follows:

        QApplication a(argc, argv);
        //A surface format specifies several parameters about the OpenGL context we want to create
        QSurfaceFormat format;
        //Set version to OpenGL 4.5 Compatibility in order to allow execution of deprecated OpenGL functions
        format.setOption(QSurfaceFormat::DeprecatedFunctions, true);
        //Enable vsync
        //Enable depth buffer

    We run OpenGL functions in a MainWindow using QOpenGL functions compatability:

    class MainWindow : public QOpenGLWindow
        QOpenGLFunctions_4_5_Compatibility* f;
        \\ ...
    void MainWindow::initializeGL()
        //load OpenGL functions
        f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_4_5_Compatibility>();

    We are confident with this on Linux and Windows. But since OpenGL is deprecated on Mac OS, we are wondering what happens, if we compile and run the code on a MAC machine. Is this going to work? If not is there a way to enable OpenGL on a MAC. AFAIK OpenGL is still available on MAC but considered deprecated.

    I'd be glad if anyone could elaborate on Qt's OpenGL capabilities on MAC :)

    Best Regards,


  • Lifetime Qt Champion

    @Dastroet said in Using QOpenGLWindow on Mac:

    But since OpenGL is deprecated

    Depricated doesn't mean it is not available. You simply try to build your app and see.

Log in to reply