diff options
-rw-r--r-- | examples/hybridshell/hybridshell.pro | 7 | ||||
-rw-r--r-- | examples/hybridshell/main.cpp | 5 | ||||
-rw-r--r-- | examples/hybridshell/main.qml | 5 | ||||
-rw-r--r-- | examples/hybridshell/resources.qrc | 6 | ||||
-rw-r--r-- | examples/qtobject/main.cpp | 7 | ||||
-rw-r--r-- | examples/qtobject/main.qml | 5 | ||||
-rw-r--r-- | examples/qtobject/qtobject.pro | 7 | ||||
-rw-r--r-- | examples/qtobject/resources.qrc | 6 |
8 files changed, 35 insertions, 13 deletions
diff --git a/examples/hybridshell/hybridshell.pro b/examples/hybridshell/hybridshell.pro index 2660d30..4ff38db 100644 --- a/examples/hybridshell/hybridshell.pro +++ b/examples/hybridshell/hybridshell.pro @@ -9,4 +9,9 @@ SOURCES += \ HEADERS += \ shell.h -DEFINES += "SOURCE_DIR=\"\\\""$$PWD"\\\"\"" +RESOURCES += \ + resources.qrc + +OTHER_FILES += \ + main.qml \ + index.html diff --git a/examples/hybridshell/main.cpp b/examples/hybridshell/main.cpp index d57966f..8c7e9b0 100644 --- a/examples/hybridshell/main.cpp +++ b/examples/hybridshell/main.cpp @@ -41,11 +41,10 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType<Shell>("Qt.labs", 1, 0, "HybridShell"); + qmlRegisterType<Shell>("QtWebChannel.Examples", 1, 0, "HybridShell"); QQuickView viewer; - viewer.engine()->addImportPath(app.applicationDirPath() + QStringLiteral("/../../src/")); - viewer.setSource(QUrl::fromLocalFile(QStringLiteral(SOURCE_DIR) + QStringLiteral("/main.qml"))); + viewer.setSource(QStringLiteral("qrc:/main.qml")); viewer.show(); return app.exec(); diff --git a/examples/hybridshell/main.qml b/examples/hybridshell/main.qml index 0dedb74..24dc729 100644 --- a/examples/hybridshell/main.qml +++ b/examples/hybridshell/main.qml @@ -42,6 +42,7 @@ import QtQuick 2.0 import QtWebChannel 1.0 +import QtWebChannel.Examples 1.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 @@ -66,12 +67,12 @@ Rectangle { onInitialized: { shell.start() - webView.url = "index.html?webChannelBaseUrl=" + webChannel.baseUrl; + webView.url = "qrc:/index.html?webChannelBaseUrl=" + webChannel.baseUrl; } } width: 480 - height: 800 + height: 600 WebView { id: webView diff --git a/examples/hybridshell/resources.qrc b/examples/hybridshell/resources.qrc new file mode 100644 index 0000000..b93a6b2 --- /dev/null +++ b/examples/hybridshell/resources.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>index.html</file> + <file>main.qml</file> + </qresource> +</RCC> diff --git a/examples/qtobject/main.cpp b/examples/qtobject/main.cpp index f11f4ba..4436862 100644 --- a/examples/qtobject/main.cpp +++ b/examples/qtobject/main.cpp @@ -41,12 +41,11 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - qmlRegisterType<TestObjectFactory>("Qt.labs", 1, 0, "TestObjectFactory"); - qmlRegisterType<TestObject>("Qt.labs", 1, 0, "TestObject"); + qmlRegisterType<TestObjectFactory>("QtWebChannel.Examples", 1, 0, "TestObjectFactory"); + qmlRegisterType<TestObject>("QtWebChannel.Examples", 1, 0, "TestObject"); QQuickView viewer; - viewer.engine()->addImportPath(app.applicationDirPath() + QStringLiteral("/../../src/")); - viewer.setSource(QUrl::fromLocalFile(QStringLiteral(SOURCE_DIR) + QStringLiteral("/main.qml"))); + viewer.setSource(QStringLiteral("qrc:/main.qml")); viewer.show(); return app.exec(); diff --git a/examples/qtobject/main.qml b/examples/qtobject/main.qml index 6dd82fa..76ef3d9 100644 --- a/examples/qtobject/main.qml +++ b/examples/qtobject/main.qml @@ -42,6 +42,7 @@ import QtQuick 2.0 import QtWebChannel 1.0 +import QtWebChannel.Examples 1.0 import QtWebKit 3.0 import QtWebKit.experimental 1.0 @@ -63,7 +64,7 @@ Rectangle { id: webChannel onRawMessageReceived: { - if (!publisher.handleRequest(rawMessage, webChannel)) { + if (!publisher.handleRawMessage(rawMessage)) { console.log("unhandled request: ", rawMessage); } } @@ -74,7 +75,7 @@ Rectangle { "initialTestObject": testObject }); - webView.url = "index.html?webChannelBaseUrl=" + webChannel.baseUrl; + webView.url = "qrc:/index.html?webChannelBaseUrl=" + webChannel.baseUrl; } } diff --git a/examples/qtobject/qtobject.pro b/examples/qtobject/qtobject.pro index e893d23..557603a 100644 --- a/examples/qtobject/qtobject.pro +++ b/examples/qtobject/qtobject.pro @@ -9,4 +9,9 @@ SOURCES += \ HEADERS += \ testobject.h -DEFINES += "SOURCE_DIR=\"\\\""$$PWD"\\\"\"" +RESOURCES += \ + resources.qrc + +OTHER_FILES += \ + main.qml \ + index.html diff --git a/examples/qtobject/resources.qrc b/examples/qtobject/resources.qrc new file mode 100644 index 0000000..b93a6b2 --- /dev/null +++ b/examples/qtobject/resources.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>index.html</file> + <file>main.qml</file> + </qresource> +</RCC> |