En esta página

QRangeModel::ItemAccess Struct

template <typename T> struct QRangeModel::ItemAccess

La plantilla ItemAccess proporciona un punto de personalización para controlar cómo QRangeModel accede a los datos de rol de elementos individuales. Más...

Esta estructura se introdujo en Qt 6.11.

Descripción detallada

Especialice esta plantilla para el tipo utilizado en su estructura de datos, e implemente los miembros readRole() y writeRole() para acceder a los datos específicos de rol de su tipo.

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;
    }
};

Una especialización de este tipo tendrá prioridad sobre cualquier comportamiento predefinido. No especialices este modelo para tipos que no poseas. Los tipos para los que se especializa ItemAccess se interpretan implícitamente como multi-role items.

© 2026 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.