summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@theqtcompany.com>2014-11-21 12:03:42 +0100
committerChristian Stromme <christian.stromme@digia.com>2014-11-21 13:43:47 +0100
commit5e33c08b025f40cd032daa4c947140bfc41b8ad6 (patch)
tree9c6cbc21622851500cb5e3296792dfdc1fe6d579
parent00e63c1e96d6d360fee28448b802a116e84c1b08 (diff)
Fix webview example for use with QtWebEngine.v5.4.0-rc1v5.4.0
When the QtWebEngine is used as a back-end we need to call QtWebEngine::initialize() or the example will fail as OpenGL context sharing needs to be enabled. Task-number: QTBUG-42745 Change-Id: I27ffc4043f759470f4d40441e62de2ba10728a01 Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
-rw-r--r--examples/webview/webview/main.cpp7
-rw-r--r--examples/webview/webview/webview.pro5
2 files changed, 12 insertions, 0 deletions
diff --git a/examples/webview/webview/main.cpp b/examples/webview/webview/main.cpp
index 7ae5d4f..4598b3f 100644
--- a/examples/webview/webview/main.cpp
+++ b/examples/webview/webview/main.cpp
@@ -47,6 +47,10 @@
#include <QQmlApplicationEngine>
#include <QtQml/QQmlContext>
+#ifdef QT_WEBVIEW_WEBENGINE_BACKEND
+#include <QtWebEngine>
+#endif // QT_WEBVIEW_WEBENGINE_BACKEND
+
// Workaround: As of Qt 5.4 QtQuick does not expose QUrl::fromUserInput.
class Utils : public QObject {
Q_OBJECT
@@ -68,6 +72,9 @@ QUrl Utils::fromUserInput(const QString& userInput)
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
+#ifdef QT_WEBVIEW_WEBENGINE_BACKEND
+ QtWebEngine::initialize();
+#endif // QT_WEBVIEW_WEBENGINE_BACKEND
QCommandLineParser parser;
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
parser.setApplicationDescription("QtWebView Browser Example");
diff --git a/examples/webview/webview/webview.pro b/examples/webview/webview/webview.pro
index 77cbe78..e02757c 100644
--- a/examples/webview/webview/webview.pro
+++ b/examples/webview/webview/webview.pro
@@ -2,6 +2,11 @@ TEMPLATE = app
QT += qml quick
+qtHaveModule(webengine) {
+ QT += webengine
+ DEFINES += QT_WEBVIEW_WEBENGINE_BACKEND
+}
+
SOURCES += main.cpp
RESOURCES += qml.qrc