Table of Contents

Interface IModelItem

Namespace
Qt.Bridge.Models
Assembly
Qt.Bridge.CSharp.Api.dll

Describes basic per-item state used to determine whether a model item can be interacted with.

public interface IModelItem

Remarks

Implement IModelItem on custom item types returned by ListModel<T> or TableModel<T> when enabled and selectable state should be controlled by the item itself instead of using the default model behavior.

This interface is most useful with richer model items, where different rows or columns may have different interaction rules. For example, a totals item might be enabled but not selectable, or a placeholder item might be neither enabled nor selectable.

public sealed class ContactItem : IModelItem, IDisplayable, IEditable
{
    public string Name { get; set; }
    public string Email { get; set; }

    public bool IsEnabled => true;
    public bool IsSelectable => true;

    public object DisplayValue => Name;

    public bool IsEditable => true;
    public object EditValue
    {
        get => Name;
        set => Name = value?.ToString() ?? string.Empty;
    }
}

In a ListModel<T> or TableModel<T> based on ContactItem, the display role would use DisplayValue, the edit role would use EditValue, and enabled/selectable state would come from IModelItem.

Properties

IsEnabled

Gets whether the item is enabled for user interaction.

bool IsEnabled { get; }

Property Value

bool

IsSelectable

Gets whether the item can be selected.

bool IsSelectable { get; }

Property Value

bool