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 |
| QModelRoleData(int role) | |
| void | clearData() |
| QVariant & | data() |
| const QVariant & | data() const |
| int | role() const |
| void | setData(T &&value) |
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.
[explicit noexcept] QModelRoleData::QModelRoleData(int role)Constructs a QModelRoleData object for the given role.
See also Qt::ItemDataRole.
[noexcept] void QModelRoleData::clearData()Clears the data held by this object. Note that the role is unchanged; only the data is cleared.
See also data().
[constexpr noexcept] QVariant &QModelRoleData::data()Returns the data held by this object as a modifiable reference.
See also setData().
[constexpr noexcept] const QVariant &QModelRoleData::data() constReturns the data held by this object.
See also setData().
[constexpr noexcept] int QModelRoleData::role() constReturns the role held by this object.
See also Qt::ItemDataRole.
[constexpr noexcept] template <typename T> void QModelRoleData::setData(T &&value)Sets the data held by this object to value. value must be of a datatype which can be stored in a QVariant.
See also data(), clearData(), and Q_DECLARE_METATYPE.
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: