XmlRole QML Type

The XmlRole element allows you to specify a role for an XmlListModel. More...

Import Statement: import .
Since: Qt 4.7

Properties

Detailed Description

See also QtDeclarative.

Property Documentation

isKey : bool

Defines whether this is a key role.

Key roles are used to to determine whether a set of values should be updated or added to the XML list model when XmlListModel::reload() is called.

See also XmlListModel.


name : string

The name for the role. This name is used to access the model data for this role.

For example, the following model has a role named "title", which can be accessed from the view's delegate:

XmlListModel {
    id: xmlModel
    // ...
    XmlRole {
        name: "title"
        query: "title/string()"
    }
}
ListView {
    model: xmlModel
    delegate: Text { text: title }
}

query : string

The relative XPath expression query for this role. The query must be relative; it cannot start with a '/'.

For example, if there is an XML document like this:


Here are some valid XPath expressions for XmlRole queries on this document:

    ...

See the W3C XPath 2.0 specification for more information.