このページでは

QRangeModel::ItemAccess Struct

template <typename T> struct QRangeModel::ItemAccess

ItemAccessテンプレートは、QRangeModel 、個々のアイテムのロールデータへのアクセス方法を制御するためのカスタマイズポイントを提供します。詳細...

この構造体は Qt 6.11 で導入されました。

詳細説明

データ構造で使用する型に対してこのテンプレートを特殊化し、readRole()writeRole() メンバを実装して、その型のロール固有のデータにアクセスします。

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

この型の特殊化は、どのような定義済みの動作よりも優先されます。自分が所有していない型に対してこのテンプレートを特殊化しないでください。ItemAccessが特殊化された型は、暗黙的に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.