Ubuntu – QML: What is the difference between a Component, Element, Property, Attribute, and Object

application-developmentprogrammingqmlubuntu-sdk

The reason why I ask, is that often languages define the same terms differently, and QML is fairly unique in some regards.

A brief explanation or analogy is preferred, where as more extensive and detailed explanations should be linked as further reading.

Thanks

Best Answer

  • Components are reusable, encapsulated QML elements with well-defined interfaces.

    Components are often defined by qml files.

    The Component element allows components to be defined within QML items rather than in a separate file. This may be useful for reusing a small component within a QML file, or for defining a component that logically belongs with other QML components within a file.

  • Elements (or types) are the predefined bricks provided by Qt Quick (or provided by the Ubuntu ui toolkit).

    Elements are declared with the their name and two curly braces. Elements may be nested in elements, thereby creating a parent-child relationship between the two elements.

    To see the standard QML elements listed by functional area, visit this page.

  • Objects are just instances of a QML type.

  • Attributes

    Every QML object type has a defined set of attributes (id, signals, properties, methods). Each instance of an object type is created with the set of attributes that have been defined for that object type.

  • Property

    A property is an attribute of an object that can be assigned a static value or bound to a dynamic expression. A property's value can be read by other objects. Generally it can also be modified by another object, unless a particular QML type has explicitly disallowed this for a specific property.