QML Basic ElementsQML's basic elements allow the easy inclusion of objects into the scene. Basic ElementsThis is a list of some of the elements readily available for users. For a complete list of QML elements, please visit the QML Elements page. Properties and Qt Declarative ModuleWhen using QML elements, keep in mind that elements may possess properties that other elements also possess. This is because QML and its underlying engine is implemented in C++ using Qt. More importantly, the chain of property inheritance is directly due to QML's use of the Qt Declarative Module and Qt's meta-object and property systems. For example, visual elements that have C++ implementation are sublcasses of QDeclarativeItem. As a result, elements such as Rectangle and Text elements inherit properties such as clip and smooth. Item ElementMany QML elements inherit Item properties. Item possesses important properties such as focus, children, and dimension properties such as width and height. Although Item has physical properties, it is not a visual element. Using Item as the top-level QML element (as the screen) will not produce a visual result, use the Rectangle element instead. Use the Item to create opacity effects, such as when creating an invisible container to hold other components. Rectangle ElementThe Rectangle element is the basic visual element, for displaying different types of items onto the screen. The Rectangle is customizable and utilizes other elements such as Gradient and BorderImage for displaying advanced customized graphics. Image ElementTo insert an image into a QML scene, merely declare an Image element. The Image element can load images in formats supported by Qt. Text ElementsThe Text and TextEdit elements display formatted text onto the screen. TextEdit features multi-line editing while the TextInput element is for single line text input. Using Elements as the Top-Level ComponentFor creating components (or displaying a simple scene), there are different elements that could be used as the top-level component. To display a simple scene, a Rectangle as the top-level component may suffice. Rectangle, FocusScope, Component, QtObject, Item, are some of the commonly used elements as the top-level component. When importing components, the top-level component is important because the top-level component's properties are the only properties exposed to the parent. For example, a Button component may be implemented using different elements as its top-level component. When this component is loaded into another QML scene, the component will retain the top-level component's properties. If a non-visual component is the top-level component, the visual properties should be aliased to the top-level to display the component properly. For more information on how to build upon QML elements, see the Importing Reusable Components document. [Previous: QML Features] [Next: Data Types] © 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. |