- Qt 6.9
- Qt Core
- C++ Classes
- QModelRoleData
- Qt 6.9.2 Reference Documentation

# QModelRoleData Class

The QModelRoleData class holds a role and the data associated to that role. More...

Header: | `#include <QModelRoleData>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS Core)` `target_link_libraries(mytarget PRIVATE Qt6::Core)`
qmake: | `QT += core`
Since: | Qt 6.0

## Detailed Description

QModelRoleData objects store an item role (which is a value from the Qt::ItemDataRole enumeration, or an arbitrary integer for a custom role) as well as the data associated with that role.

A QModelRoleData object is typically created by views or delegates, setting which role they want to fetch the data for. The object is then passed to models (see QAbstractItemModel::multiData()), which populate the data corresponding to the role stored. Finally, the view visualizes the data retrieved from the model.

See also Model/View Programming and QModelRoleDataSpan.