- Qt 6.11
- Qt Core
- C++ Classes
- ItemAccess
- Qt 6.11.2 Reference Documentation

# QRangeModel::ItemAccess Struct

template <typename T> struct QRangeModel::ItemAccess

The ItemAccess template provides a customization point to control how QRangeModel accesses role data of individual items. More...

This struct was introduced in Qt 6.11.

## Detailed Description

Specialize this template for the type used in your data structure, and implement `readRole()` and `writeRole()` members to access the role- specific data of your type.

     template <>
     struct QRangeModel::ItemAccess<ItemType>
     {
         static QVariant readRole(const ItemType &item, int role)
         {
             switch (role) {
                 // ...
             }
             return {};
         }

         static bool writeRole(ItemType &item, const QVariant &data, int role)
         {
             bool ok = false;
             switch (role) {
                 // ...
             }

             return ok;
         }
     };

A specialization of this type will take precedence over any predefined behavior. Do not specialize this template for types you do not own. Types for which ItemAccess is specialized are implicitly interpreted as multi-role items.