QRangeModel::ItemAccess Struct
template <typename T> struct QRangeModel::ItemAccessItemAccess 模板提供了一个自定义点,用于控制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.