ObjectModel QML Type | QtQml 5.3

- Qt 5.3
- Qt QML
- QML Types
- ObjectModel QML Type
- Qt 5.3.2 Reference Documentation

# ObjectModel QML Type

Defines a set of items to be used as a model More...

Import Statement: | `import QtQml.Models 2.0`

- List of all members, including inherited members

## Properties

- count : int

## Attached Properties

- index : int

## Detailed Description

A ObjectModel contains the visual items to be used in a view. When a ObjectModel is used in a view, the view does not require a delegate since the ObjectModel already contains the visual delegate (items).

An item can determine its index within the model via the index attached property.

The example below places three colored rectangles in a ListView.

    import QtQuick 2.0

    Rectangle {
        ObjectModel {
            id: itemModel
            Rectangle { height: 30; width: 80; color: "red" }
            Rectangle { height: 30; width: 80; color: "green" }
            Rectangle { height: 30; width: 80; color: "blue" }
        }

        ListView {
            anchors.fill: parent
            model: itemModel
        }
    }

See also Qt Quick Examples - Views.

## Property Documentation

count : int

The number of items in the model. This property is readonly.

## Attached Property Documentation

.index : int

This attached property holds the index of this delegate's item within the model.

It is attached to each instance of the delegate.