Auf dieser Seite

QRangeModel::ItemAccess Struct

template <typename T> struct QRangeModel::ItemAccess

Die ItemAccess-Vorlage bietet einen Anpassungspunkt, um zu steuern, wie QRangeModel auf die Rollendaten der einzelnen Elemente zugreift. Mehr...

Diese Struktur wurde in Qt 6.11 eingeführt.

Detaillierte Beschreibung

Spezialisieren Sie diese Vorlage für den in Ihrer Datenstruktur verwendeten Typ und implementieren Sie die Mitglieder readRole() und writeRole(), um auf die rollenspezifischen Daten Ihres Typs zuzugreifen.

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

Eine Spezialisierung dieses Typs hat Vorrang vor jedem vordefinierten Verhalten. Spezialisieren Sie diese Vorlage nicht für Typen, die Sie nicht besitzen. Typen, für die ItemAccess spezialisiert ist, werden implizit als multi-role items interpretiert.

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