summaryrefslogtreecommitdiffstats
path: root/examples/webview
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webview')
-rw-r--r--examples/webview/webview/main.cpp13
-rw-r--r--examples/webview/webview/main.qml2
2 files changed, 14 insertions, 1 deletions
diff --git a/examples/webview/webview/main.cpp b/examples/webview/webview/main.cpp
index 8525bc2..b569129 100644
--- a/examples/webview/webview/main.cpp
+++ b/examples/webview/webview/main.cpp
@@ -38,14 +38,27 @@
**
****************************************************************************/
+#include <QtCore/QUrl>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
+#include <QtQml/QQmlContext>
+
+// Workaround: As of Qt 5.4 QtQuick does not expose QUrl::fromUserInput.
+class Utils : public QObject {
+ Q_OBJECT
+public:
+ Utils(QObject* parent = 0) : QObject(parent) { }
+ Q_INVOKABLE static QUrl fromUserInput(const QString& userInput) { return QUrl::fromUserInput(userInput); }
+};
+
+#include "main.moc"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty("utils", new Utils(&engine));
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
diff --git a/examples/webview/webview/main.qml b/examples/webview/webview/main.qml
index 5b1e951..57b3e7a 100644
--- a/examples/webview/webview/main.qml
+++ b/examples/webview/webview/main.qml
@@ -75,7 +75,7 @@ ApplicationWindow {
anchors.margins: topLevel.width / 30
text: qsTr("Go")
onClicked: {
- webView.url = addressField.text
+ webView.url = utils.fromUserInput(addressField.text)
}
}