KRoleNames QML Type

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

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

Methods

  • int role(var roleName) (since 6.0)
  • roleName(int role) (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).

Method Documentation

[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.


[since 6.0] roleName(int role)

Maps role number to role name.

Returns an empty string if role is not found in attachee model's roleNames() hash map.

This method was introduced in 6.0.