Class ListModel
Represents a flat one-dimensional model with no parent-child hierarchy.
public abstract class ListModel : Model
- Inheritance
-
ListModel
- Derived
-
ListModel<T>
- Inherited Members
Remarks
Use ListModel or ListModel<T> when your data is naturally arranged as a simple sequence of items, such as a list of names, products, or messages. This base class fixes the hierarchical parts of Model so subclasses can focus on item count, item data, and list-specific change notifications.
In practical terms, a list model has exactly one column at the root level and no child items. Valid parent indexes are treated as having zero rows and zero columns. If your data is arranged as rows and columns, prefer TableModel instead.
Most applications should derive from ListModel<T> rather than directly from ListModel, because the generic form automatically maps item values or public item properties to named roles.
Methods
ColumnCount(ModelIndex)
Returns the number of columns for the specified parent index.
public override sealed int ColumnCount(ModelIndex parent)
Parameters
parentModelIndex
Returns
HasChildren(ModelIndex)
Returns whether the specified parent item has any children.
public override sealed bool HasChildren(ModelIndex parent)
Parameters
parentModelIndex
Returns
Index(int, int, ModelIndex)
Creates an index that identifies the item at the specified row and column under a parent.
public override sealed ModelIndex Index(int row, int column, ModelIndex parent)
Parameters
Returns
- ModelIndex
Parent(ModelIndex)
Returns the parent index for the specified item.
public override sealed ModelIndex Parent(ModelIndex index)
Parameters
indexModelIndex
Returns
- ModelIndex
Sibling(int, int, ModelIndex)
Returns another item with the same parent as the specified item.
public override sealed ModelIndex Sibling(int row, int column, ModelIndex index)
Parameters
Returns
- ModelIndex