KRoleNames QML Type
Maps role numbers and names of the attached model. More...
| Import Statement: | import org.kde.kitemmodels |
| Since: | 6.0 |
Attached Methods
Detailed Description
Attach KRoleNames to a model 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 a role enum is not available in QML (for example, when it is not exported via Q_ENUM) but role names are known; or to maintain consistency with view delegates (which use role names as properties).
Attached Method Documentation
[since 6.0] int role(string roleName)
Maps role name to role number.
Returns -1 if roleName is not found in the attached model's roleNames() hash map.
This method was introduced in 6.0.
[since 6.0] string roleName(int role)
Maps role number to role name.
Returns an empty string if role is not found in the attached model's roleNames() hash map.
This method was introduced in 6.0.