diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index f1d2f63756c6cccbcf5e734fe22aa0242155e2ba..04539800a5a5d1d0c50394b4bb30006b479e4202 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -3132,7 +3132,7 @@ QImage QQuickWindow::grabWindow()
 
         QOpenGLContext context;
         context.setFormat(requestedFormat());
-        context.setShareContext(QOpenGLContextPrivate::globalShareContext());
+        context.setShareContext(qt_gl_global_share_context());
         context.create();
         context.makeCurrent(this);
         d->context->initialize(&context);
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index 73b64b4f9bb7ff386c47adc19f853794eed2a94a..064d363412b0ecb960ad85b2efcde9c762c6d482 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -334,8 +334,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window)
     if (!gl) {
         gl = new QOpenGLContext();
         gl->setFormat(window->requestedFormat());
-        if (QOpenGLContextPrivate::globalShareContext())
-            gl->setShareContext(QOpenGLContextPrivate::globalShareContext());
+        if (qt_gl_global_share_context())
+            gl->setShareContext(qt_gl_global_share_context());
         if (!gl->create()) {
             const bool isEs = gl->isOpenGLES();
             delete gl;
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index 793a24742797c56108c58ff732db46e87aaabf2c..84ae3f818bf7581de9f34726faf013c8da6b7208 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -889,8 +889,8 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window)
 
         if (!w->thread->gl) {
             w->thread->gl = new QOpenGLContext();
-            if (QOpenGLContextPrivate::globalShareContext())
-                w->thread->gl->setShareContext(QOpenGLContextPrivate::globalShareContext());
+            if (qt_gl_global_share_context())
+                w->thread->gl->setShareContext(qt_gl_global_share_context());
             w->thread->gl->setFormat(w->window->requestedFormat());
             if (!w->thread->gl->create()) {
                 const bool isEs = w->thread->gl->isOpenGLES();
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index 70f80689f54e80b35d27e8a6f5b9e510ec2d09db..671b341046973a8c3f994b40f96847e57f99463c 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -162,8 +162,8 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window)
         RLDEBUG(" - creating GL context");
         m_gl = new QOpenGLContext();
         m_gl->setFormat(window->requestedFormat());
-        if (QOpenGLContextPrivate::globalShareContext())
-            m_gl->setShareContext(QOpenGLContextPrivate::globalShareContext());
+        if (qt_gl_global_share_context())
+            m_gl->setShareContext(qt_gl_global_share_context());
         bool created = m_gl->create();
         if (!created) {
             const bool isEs = m_gl->isOpenGLES();
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index 91f4ac4bb7720d2675e9692eb5651c0a5cfbf345..fed39b18a556d92e005eabd15155582f50ffaf93 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -631,8 +631,8 @@ void QQuickWidgetPrivate::createContext()
     context = new QOpenGLContext;
     context->setFormat(offscreenWindow->requestedFormat());
 
-    if (QOpenGLContextPrivate::globalShareContext())
-        context->setShareContext(QOpenGLContextPrivate::globalShareContext());
+    if (qt_gl_global_share_context())
+        context->setShareContext(qt_gl_global_share_context());
     if (!context->create()) {
         const bool isEs = context->isOpenGLES();
         delete context;
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index b048337cad34210e351acd2cae3600bf45075550..908b198e2d05539114919ed29bfa4d7626915764 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -460,7 +460,7 @@ int main(int argc, char ** argv)
     if (options.contextSharing) {
         shareContext.reset(new QOpenGLContext);
         shareContext->create();
-        QOpenGLContextPrivate::setGlobalShareContext(shareContext.data());
+        qt_gl_set_global_share_context(shareContext.data());
     }
 
     int exitCode = 0;