在QML的UbuntuApplication Context Property

我们可以在Ubuntu SDK的文档中可以看到UbuntuApplication API。但是我们看不到它的具体的用法。在这篇文章中,我们来通过如下的方法来查看一下该如何使用该API。

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: "ubuntuapplication.liu-xiao-guo"/*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(60)height: units.gu(85)Page {title: i18n.tr("ubuntuapplication")Text {text: UbuntuApplication.applicationName}Component.onCompleted: {var keys = Object.keys(UbuntuApplication);for(var i = 0; i < keys.length; i++) {var key = keys[i];// prints all properties, signals, functions from objectconsole.log(key + ' : ' + UbuntuApplication[key]);if (key === "x") {rect[key] = 100;}}}}}

运行我们的应用:

Starting /usr/lib/x86_64-linux-gnu/qt5/bin/qmlscene…qml: objectName : qml: applicationName : ubuntuapplication.liu-xiao-guoqml: objectNameChanged : function() { [code] }qml: applicationNameChanged : function() { [code] }

从上面的输出可以看出来,,UbuntuApplication目前没有多少的属性让我们来使用。其中的applicationName,我们也可以使用Qt.application.name来的到。

初初尝试着拥抱的人,一派新鲜幸福都来不及沉浸,

在QML的UbuntuApplication Context Property

相关文章:

你感兴趣的文章:

标签云: