在QML的UbuntuApplication Context Property

来源:互联网 发布:2017淘宝直通车 编辑:程序博客网 时间:2024/06/16 19:24

我们可以在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 manifest    applicationName: "ubuntuapplication.liu-xiao-guo"    /*     This property enables the application to change orientation     when the device is rotated. The default is false.    */    //automaticOrientation: true    // Removes the old toolbar and enables new features of the new header.    useDeprecatedToolbar: false    width: 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 object                console.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来的到。 

0 0
原创粉丝点击