KRoleNames QML Type (Uncreatable)

A mapper between roles and role names of an attachee model. More...

Import Statement: import org.kde.kitemmodels
Since: 6.0

Note: This is an uncreatable type. It cannot be instantiated in QML.

Attached Methods

  • int role(var roleName) (since 6.0)

Detailed Description

KRoleNames exposes runtime-invokable methods to map from roles to role names and vice-versa. It can be used to retrieve data from a model in an imperative fashion when enum with roles is not available at runtime (i.e. not exported via Q_ENUM macro) but role names are known; or just to maintain consistency with view delegates (which use role names as properties).

Attached Method Documentation

[attached, since 6.0] int role(var roleName)

Maps role name to role number.

Returns -1 if role name is not found in attachee model's roleNames() hash map.

This method was introduced in 6.0.