Ubuntu应用开发

所需积分/C币:21 2015-01-04 16:06:58 1.59MB PDF
收藏 收藏
举报

在这个文档中介绍如何在Ubuntu平台上开发应用
Native language otog QML structure Brief example of QML notation Rectangle i id: canvas width: 200 height: 200 color: blue QML is declarative. You point out what kind of object you need and then specify all its attributes The Ubuntu sdk will auto-complete available attribute and method names etc Specifiying an " id' lets you refer to the object elsewhere (c)2013 Canonical doo gmlscene QML structure Objects can be nested Rectang lle t id: rect width: 300 X height: 300 co lor:orange Image i id: logo source: calculator. svg anchors. centerIn parent height: rect height /2 width: rect width /2 Note how rect is referred to in the definition of the Image object QML structure QML imports s To use functionality and assets(like Java Script bits) from certain modules in your app, you need to first import the module You can do this by adding a line like the following at the top of your code import <ModuleIdentifier> <Version Number> as <Qualifier> s For example: import QtQuick 2.0 The <Version Number> is a version of the form Major Version. Minor Version which specifies which definitions of various object types and Java Script resources will be made available due to the import QML component Components are reusable encapsulated Qml elements with well- defined interfaces Components are often defined by component files Component element essentially allows QML components to be defined inline within a qml document import QtQuick 2.0 Item t width 100; height: 100 Component i id: redSquare Rectangle t color red width: 10 height: 10 Loader source Component: redsquare; x: 20 Binding Property values Rectangle i width: 400 height: 2 100 color: lightblue Image i width: parent width source: down load. png Property values can be bound to other values o Automatically updated o Use parent for accessing parent or a given id to o access another element (like sibling) Creating Property Bindings from JavaScript o a property with a binding is automatically updated as necessary However, if the property is later assigned a static value from a Java Script statement, the binding will be removed Rectangle i width: 100; height: width 2 focus: true Keys on SpacePressed t height width 3// Now the binding is removed! Correct way Rectangle width: 100; height: width 2 focus: true Keys on SpacePressed t height Qt binding (function oi return width 3 3) Startup scripts Sometimes it is necessary to run a piece of code at application startup o Or more specifically, when a component is instantiated Having this code as a global piece of script in an external script file is nol a good ide ea o All relevant pieces of the qml scope chain might not be fully initialized when the code is run The best solution is to use the attached property on Completed of the Component element o Executed once the component has been fully initialized Page i Rectangle t width: 400; height: 2 *100 color: lightblue" Component on Completed t console. log ( You can initialize state here.") http://goo.glxvun4t

...展开详情
试读 33P Ubuntu应用开发
立即下载 低至0.43元/次 身份认证VIP会员低至7折
    抢沙发
    一个资源只可评论一次,评论内容不能少于5个字
    上传资源赚积分,得勋章
    最新推荐
    Ubuntu应用开发 21积分/C币 立即下载
    1/33
    Ubuntu应用开发第1页
    Ubuntu应用开发第2页
    Ubuntu应用开发第3页
    Ubuntu应用开发第4页
    Ubuntu应用开发第5页
    Ubuntu应用开发第6页
    Ubuntu应用开发第7页
    Ubuntu应用开发第8页
    Ubuntu应用开发第9页
    Ubuntu应用开发第10页

    试读已结束,剩余23页未读...

    21积分/C币 立即下载 >