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.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.