Qt Reference Documentation

QML VisualItemModel Element

The VisualItemModel allows items to be provided to a view. More...

  • List of all members, including inherited members
  • Properties

    Attached Properties

    Detailed Description

    A VisualItemModel contains the visual items to be used in a view. When a VisualItemModel is used in a view, the view does not require a delegate since the VisualItemModel 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 Qt 4.7
    
     Rectangle {
         VisualItemModel {
             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 VisualItemModel example.

    Property Documentation

    read-onlycount : int

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


    Attached Property Documentation

    read-onlyVisualItemModel.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.


    X

    Thank you for giving your feedback.

    Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.