使用URL dispatcher的范例

2)创建调用应用

这个应用其实很简单。我们直接创建一个基本的QML template应用,同时修改我们的main.qml如下:

import QtQuick 2.0import Ubuntu.Components 1.1/*!\brief MainView with a Label and Button elements.*/MainView {// objectName for functional testing purposes (autopilot-qt5)objectName: "mainView"// Note! applicationName needs to match the "name" field of the click manifestapplicationName: "com.ubuntu.developer.unknown.launchmyapp"/*This property enables the application to change orientationwhen the device is rotated. The default is false.*///automaticOrientation: true// Removes the old toolbar and enables new features of the new header.useDeprecatedToolbar: falsewidth: units.gu(100)height: units.gu(75)Page {title: i18n.tr("LaunchMyApp")Column {spacing: units.gu(1)anchors {margins: units.gu(2)fill: parent}Button {objectName: "button"width: parent.widthtext: i18n.tr("Launch MyApp")onClicked: {Qt.openUrlExternally("launchmyapp:///123");}}Button {objectName: "button"width: parent.widthtext: i18n.tr("Open MyApp")onClicked: {Qt.openUrlExternally("appid://com.ubuntu.developer.unknown.myapp/MyApp/current-user-version");}}}}}这里我们使用了两种方法来调用我们的“MyApp”。第一种是通过:

Qt.openUrlExternally("launchmyapp:///123");这种方法的好处是可以传人我们需要的参数,并解析,从而对于不同的参数可以得到不同的响应。

另外一种方式是通过:

,孤单不是与生俱来,而是由你爱上一个人的那一刻开始。

使用URL dispatcher的范例

相关文章:

你感兴趣的文章:

标签云: