We can see the ubuntuapplication API in the Ubuntu SDK documentation. But we do not see the specific usage of it. In this article, let's look at how to use the API in the following ways.
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" /* The 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 (height:units.gu) page {title:i18n.tr ("Ubuntuapplicat Ion ") 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; } } } }}
To run our application:
Starting/usr/lib/x86_64-linux-gnu/qt5/bin/qmlscene...qml:objectname:qml:applicationname: Ubuntuapplication.liu-xiao-guoqml:objectnamechanged:function () {[Code]}qml:applicationnamechanged:function () {[C ODE]}
As can be seen from the above output, Ubuntuapplication currently does not have many attributes to let us use. One of the applicationname, we can also use Qt.application.name to come.
Ubuntuapplication Context Property in QML