diff --git a/examples/webengine/quicknanobrowser/main.cpp b/examples/webengine/quicknanobrowser/main.cpp
index 6c2f91de6dd9397800213f7e725429cc692bbc96..1e592f3e11238e1f93b69be6a47804f2fc96e46a 100644
--- a/examples/webengine/quicknanobrowser/main.cpp
+++ b/examples/webengine/quicknanobrowser/main.cpp
@@ -47,18 +47,13 @@ typedef QApplication Application;
 #include <QtGui/QGuiApplication>
 typedef QGuiApplication Application;
 #endif
-#include <QtQuick/private/qsgcontext_p.h>
+#include <qtwebengineglobal.h>
 
 int main(int argc, char **argv)
 {
     Application app(argc, argv);
 
-    // This is currently needed by all QtWebEngine application using the HW accelerated QQuickWebView.
-    // It enables sharing between the QOpenGLContext of all QQuickWindows of the application.
-    // We have to do so until we expose a public API for it, or chose enable it by default in Qt 5.3.0.
-    QOpenGLContext shareContext;
-    shareContext.create();
-    QSGContext::setSharedOpenGLContext(&shareContext);
+    QWebEngine::initialize();
 
     ApplicationEngine appEngine;
 
diff --git a/examples/webengine/quicknanobrowser/quicknanobrowser.pro b/examples/webengine/quicknanobrowser/quicknanobrowser.pro
index f1b665932482e81bc9144f70697a492e5302a430..3628b817e341503a81f808bd8205de289c731ede 100644
--- a/examples/webengine/quicknanobrowser/quicknanobrowser.pro
+++ b/examples/webengine/quicknanobrowser/quicknanobrowser.pro
@@ -10,8 +10,7 @@ OTHER_FILES += quickwindow.qml
 
 RESOURCES += resources.qrc
 
-QT += qml quick
-QT_PRIVATE += quick-private gui-private core-private
+QT += qml quick webengine
 
 qtHaveModule(widgets) {
     QT += widgets # QApplication is required to get native styling with QtQuickControls
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 99862235fc9431c9835ea45a78aed9454abcd0c9..628aa6ed2a1369e055ddd1b1c17578a94ea15d0c 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -249,7 +249,9 @@ void ShareGroupQtQuick::AboutToAddFirstContext()
 {
     // This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering.
     QOpenGLContext *shareContext = QSGContext::sharedOpenGLContext();
-    Q_ASSERT(shareContext);
+    if (!shareContext) {
+        qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QWebEngine::initialize() in your main() function.");
+    }
     m_shareContextQtQuick = make_scoped_refptr(new QtShareGLContext(shareContext));
 }
 
diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4aa72ba6f0c681b3ae37ab94421232f8e21da242
--- /dev/null
+++ b/src/webengine/api/qtwebengineglobal.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights.  These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtwebengineglobal.h"
+
+#include <private/qsgcontext_p.h>
+#include <QGuiApplication>
+
+static QOpenGLContext *shareContext;
+
+static void deleteShareContext()
+{
+    delete shareContext;
+    shareContext = 0;
+}
+
+void QWebEngine::initialize()
+{
+    QCoreApplication *app = QCoreApplication::instance();
+    if (!app) {
+        qFatal("QWebEngine::initialize() must be called after the construction of the application object.");
+        return;
+    }
+    if (app->thread() != QThread::currentThread()) {
+        qFatal("QWebEngine::initialize() must be called from the Qt gui thread.");
+        return;
+    }
+
+    if (shareContext)
+        return;
+
+    shareContext = new QOpenGLContext;
+    shareContext->create();
+    qAddPostRoutine(deleteShareContext);
+    QSGContext::setSharedOpenGLContext(shareContext);
+}
+
diff --git a/src/webengine/api/qtwebengineglobal.h b/src/webengine/api/qtwebengineglobal.h
index 46f77c55f545beaedfe8799a049193874b815a77..f5fa479d9fb22de744a98e72687a0aeb5bc909eb 100644
--- a/src/webengine/api/qtwebengineglobal.h
+++ b/src/webengine/api/qtwebengineglobal.h
@@ -55,6 +55,12 @@ QT_BEGIN_NAMESPACE
 #  define Q_WEBENGINE_EXPORT
 #endif
 
+class Q_WEBENGINE_EXPORT QWebEngine
+{
+public:
+    static void initialize();
+};
+
 QT_END_NAMESPACE
 
 #endif // QTWEBENGINEGLOBAL_H
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index 42602bbc6406d1150d60ae1d451bb33c8af7fb74..ad1a31b54848a837ba6b9a762ddb5b9d12ba757a 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -15,6 +15,7 @@ SOURCES = \
         api/qquickwebengineloadrequest.cpp \
         api/qquickwebenginenewviewrequest.cpp \
         api/qquickwebengineview.cpp \
+        api/qtwebengineglobal.cpp \
         render_widget_host_view_qt_delegate_quick.cpp \
         ui_delegates_manager.cpp
 
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index 5883574d38dea0035409ffbb1c2edaccc93d59f0..98d836a10d8e73c209f439372b3beea4fbedc0dd 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -1,7 +1,6 @@
 include(../tests.pri)
 
 QT += qmltest
-QT_PRIVATE += quick-private
 
 IMPORTPATH += $$PWD/data
 
diff --git a/tests/auto/quick/qquickwebviewgraphics/tst_qquickwebviewgraphics.cpp b/tests/auto/quick/qquickwebviewgraphics/tst_qquickwebviewgraphics.cpp
index 4411107c48dfe0ee0e2a6bcd9df33985620327f0..213420b13770eee143c371e1edbc1d2c3bc7db96 100644
--- a/tests/auto/quick/qquickwebviewgraphics/tst_qquickwebviewgraphics.cpp
+++ b/tests/auto/quick/qquickwebviewgraphics/tst_qquickwebviewgraphics.cpp
@@ -43,7 +43,8 @@
 #include <QQmlContext>
 #include <QQuickView>
 #include <QQuickItem>
-#include <QtQuick/private/qsgcontext_p.h>
+#include <QPainter>
+#include <qtwebengineglobal.h>
 
 class TestView : public QQuickView {
     Q_OBJECT
@@ -111,12 +112,7 @@ void tst_QQuickWebViewGraphics::initTestCase()
 #if defined(TST_QQUICKWEBVIEWGRAPHICS_SOFTWARE)
     qApp->setProperty("QQuickWebEngineView_DisableHardwareAcceleration", QVariant(true));
 #else
-    // This is currently needed by all QtWebEngine application using the HW accelerated QQuickWebView.
-    // It enables sharing between the QOpenGLContext of all QQuickWindows of the application.
-    // We have to do so until we expose a public API for it, or chose enable it by default in Qt 5.3.0.
-    QOpenGLContext *shareContext = new QOpenGLContext;
-    shareContext->create();
-    QSGContext::setSharedOpenGLContext(shareContext);
+    QWebEngine::initialize();
 #endif
 }
 
diff --git a/tests/auto/quick/shared/qt_webengine_quicktest.h b/tests/auto/quick/shared/qt_webengine_quicktest.h
index 92e9889ef3707f5d4e87c6c3b393242af4958d99..275e40dd2c713f1eccbe08351a036f2b2077e1e5 100644
--- a/tests/auto/quick/shared/qt_webengine_quicktest.h
+++ b/tests/auto/quick/shared/qt_webengine_quicktest.h
@@ -51,7 +51,7 @@
 #endif
 
 #include "qopenglcontext.h"
-#include <QtQuick/private/qsgcontext_p.h>
+#include <qtwebengineglobal.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -72,11 +72,8 @@ QT_BEGIN_NAMESPACE
         qputenv("QTWEBENGINEPROCESS_PATH", QWP_PATH); \
         if (!QCoreApplication::instance()) \
             app = new Application(argc, argv); \
-        QOpenGLContext *shareContext = new QOpenGLContext(); \
-        shareContext->create(); \
-        QSGContext::setSharedOpenGLContext(shareContext); \
+        QWebEngine::initialize(); \
         int i = quick_test_main(argc, argv, #name, QUICK_TEST_SOURCE_DIR); \
-        delete shareContext; \
         delete app; \
         return i; \
     }
diff --git a/tests/auto/quick/tests.pri b/tests/auto/quick/tests.pri
index c2e47c653f5e38d15036d51710a45804fe0dc614..932407e660f9efa163f4ec00285e93c28e2f4172 100644
--- a/tests/auto/quick/tests.pri
+++ b/tests/auto/quick/tests.pri
@@ -9,8 +9,7 @@ TARGET = tst_$$TARGET
 SOURCES += $${TARGET}.cpp
 INCLUDEPATH += $$PWD
 
-QT += testlib network quick
-QT_PRIVATE += quick-private gui-private core-private
+QT += testlib network quick webengine
 
 macx: CONFIG -= app_bundle
 
diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp
index 6c2f91de6dd9397800213f7e725429cc692bbc96..1e592f3e11238e1f93b69be6a47804f2fc96e46a 100644
--- a/tests/quicktestbrowser/main.cpp
+++ b/tests/quicktestbrowser/main.cpp
@@ -47,18 +47,13 @@ typedef QApplication Application;
 #include <QtGui/QGuiApplication>
 typedef QGuiApplication Application;
 #endif
-#include <QtQuick/private/qsgcontext_p.h>
+#include <qtwebengineglobal.h>
 
 int main(int argc, char **argv)
 {
     Application app(argc, argv);
 
-    // This is currently needed by all QtWebEngine application using the HW accelerated QQuickWebView.
-    // It enables sharing between the QOpenGLContext of all QQuickWindows of the application.
-    // We have to do so until we expose a public API for it, or chose enable it by default in Qt 5.3.0.
-    QOpenGLContext shareContext;
-    shareContext.create();
-    QSGContext::setSharedOpenGLContext(&shareContext);
+    QWebEngine::initialize();
 
     ApplicationEngine appEngine;
 
diff --git a/tests/quicktestbrowser/quicktestbrowser.pro b/tests/quicktestbrowser/quicktestbrowser.pro
index 83baa73f16a4f55fe28c47ce6c70474430d45da5..b0146a6890f71e8d83184a311545c9441c24254d 100644
--- a/tests/quicktestbrowser/quicktestbrowser.pro
+++ b/tests/quicktestbrowser/quicktestbrowser.pro
@@ -13,8 +13,7 @@ OTHER_FILES += ContextMenuExtras.qml \
 
 RESOURCES += resources.qrc
 
-QT += qml quick
-QT_PRIVATE += quick-private gui-private core-private
+QT += qml quick webengine
 
 qtHaveModule(widgets) {
     QT += widgets # QApplication is required to get native styling with QtQuickControls