Auf dieser Seite

QConcatenateTablesProxyModel Class

Die Klasse „QConcatenateTablesProxyModel“ fungiert als Proxy für mehrere Quellmodelle und fügt deren Zeilen zusammen. Mehr dazu...

Kopfzeile: #include <QConcatenateTablesProxyModel>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Erbt von: QAbstractItemModel

Öffentliche Funktionen

QConcatenateTablesProxyModel(QObject *parent = nullptr)
virtual ~QConcatenateTablesProxyModel()
void addSourceModel(QAbstractItemModel *sourceModel)
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
QModelIndex mapToSource(const QModelIndex &proxyIndex) const
void removeSourceModel(QAbstractItemModel *sourceModel)
QList<QAbstractItemModel *> sourceModels() const

Neu implementierte öffentliche Funktionen

virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
virtual Qt::ItemFlags flags(const QModelIndex &index) const override
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override
virtual QMap<int, QVariant> itemData(const QModelIndex &proxyIndex) const override
virtual QMimeData *mimeData(const QModelIndexList &indexes) const override
virtual QStringList mimeTypes() const override
virtual QModelIndex parent(const QModelIndex &index) const override
(since 6.9.0) virtual QHash<int, QByteArray> roleNames() const override
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override
virtual bool setItemData(const QModelIndex &proxyIndex, const QMap<int, QVariant> &roles) override
virtual QSize span(const QModelIndex &index) const override

Detaillierte Beschreibung

QConcatenateTablesProxyModel nimmt mehrere Quellmodelle entgegen und verknüpft deren Zeilen miteinander.

Mit anderen Worten: Der Proxy enthält alle Zeilen des ersten Quellmodells, gefolgt von allen Zeilen des zweiten Quellmodells und so weiter.

Wenn die Quellmodelle nicht die gleiche Anzahl an Spalten haben, verfügt der Proxy nur über so viele Spalten wie das Quellmodell mit der geringsten Spaltenanzahl. Zusätzliche Spalten in anderen Quellmodellen werden einfach ignoriert.

Quellmodelle können zur Laufzeit hinzugefügt und entfernt werden, wobei die Spaltenanzahl entsprechend angepasst wird.

Dieser Proxy erbt nicht von „ QAbstractProxyModel “, da er mehrere Quellmodelle anstelle eines einzigen verwendet.

Es werden nur flache Modelle (Listen und Tabellen) unterstützt, Baummodelle hingegen nicht.

Siehe auch „ QAbstractProxyModel“ , „Model/View-Programmierung“, „ QIdentityProxyModel “ und „ QAbstractItemModel “.

Dokumentation zu Mitgliedsfunktionen

[explicit] QConcatenateTablesProxyModel::QConcatenateTablesProxyModel(QObject *parent = nullptr)

Erstellt ein Proxy-Modell zum Verketten von Zeilen mit dem angegebenen „ parent “.

[virtual noexcept] QConcatenateTablesProxyModel::~QConcatenateTablesProxyModel()

Löscht dieses Proxy-Modell.

void QConcatenateTablesProxyModel::addSourceModel(QAbstractItemModel *sourceModel)

Fügt ein Quellmodell „ sourceModel “ unterhalb aller zuvor hinzugefügten Quellmodelle hinzu.

Die Eigentumsverhältnisse von „ sourceModel “ bleiben davon unberührt.

Dasselbe Quellmodell kann nicht mehr als einmal hinzugefügt werden.

[override virtual] bool QConcatenateTablesProxyModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const

Implementiert: ` QAbstractItemModel::canDropMimeData` (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const.

[override virtual] int QConcatenateTablesProxyModel::columnCount(const QModelIndex &parent = QModelIndex()) const

Implementiert: ` QAbstractItemModel::columnCount(const QModelIndex &parent) const`.

Diese Methode gibt die Spaltenanzahl des Quellmodells mit der geringsten Anzahl an Spalten zurück.

[override virtual] QVariant QConcatenateTablesProxyModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const

Implementiert neu: ` QAbstractItemModel::data(const QModelIndex &index, int role) const`.

Siehe auch setData().

[override virtual] bool QConcatenateTablesProxyModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)

Implementiert: ` QAbstractItemModel::dropMimeData` (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent).

QConcatenateTablesProxyModel Behandelt das Ablegen auf einem Element, zwischen Elementen und nach dem letzten Element. In allen Fällen wird der Aufruf an das zugrunde liegende Quellmodell weitergeleitet. Beim Ablegen auf einem Element wird das Quellmodell für dieses Element aufgerufen. Beim Ablegen zwischen Elementen wird das Quellmodell unmittelbar unterhalb der Ablageposition aufgerufen. Beim Ablegen nach dem letzten Element wird das letzte Quellmodell aufgerufen.

[override virtual] Qt::ItemFlags QConcatenateTablesProxyModel::flags(const QModelIndex &index) const

Implementiert: ` QAbstractItemModel::flags(const QModelIndex &index) const`.

Gibt die Flags für den angegebenen Index zurück. Ist der ` index ` gültig, stammen die Flags aus dem Quellmodell für dieses ` index`. Ist der ` index ` ungültig (wie beispielsweise zur Feststellung, ob das Ablegen auf einem leeren Bereich in der Ansicht zulässig ist), werden die Flags aus dem ersten Modell zurückgegeben.

[override virtual] QVariant QConcatenateTablesProxyModel::headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const

Umsetzt: ` QAbstractItemModel::headerData(int section, Qt::Orientation orientation, int role) const`.

Diese Methode gibt die horizontalen Kopfdaten für das erste Quellmodell sowie die vertikalen Kopfdaten für das Quellmodell zurück, das der jeweiligen Zeile entspricht.

[override virtual] QModelIndex QConcatenateTablesProxyModel::index(int row, int column, const QModelIndex &parent = QModelIndex()) const

Implementiert: ` QAbstractItemModel::index(int row, int column, const QModelIndex &parent) const`.

[override virtual] QMap<int, QVariant> QConcatenateTablesProxyModel::itemData(const QModelIndex &proxyIndex) const

Implementiert neu: ` QAbstractItemModel::itemData(const QModelIndex &index) const`.

Siehe auch setItemData().

[invokable] QModelIndex QConcatenateTablesProxyModel::mapFromSource(const QModelIndex &sourceIndex) const

Gibt den Proxy-Index für ein bestimmtes ` sourceIndex` zurück, das aus einem beliebigen der Quellmodelle stammen kann.

Hinweis: Diese Funktion kann über das Metaobjektsystem und aus QML aufgerufen werden. Siehe Q_INVOKABLE.

[invokable] QModelIndex QConcatenateTablesProxyModel::mapToSource(const QModelIndex &proxyIndex) const

Gibt den Quellindex für ein bestimmtes ` proxyIndex` zurück.

Hinweis: Diese Funktion kann über das Metaobjektsystem und aus QML aufgerufen werden. Siehe Q_INVOKABLE.

[override virtual] QMimeData *QConcatenateTablesProxyModel::mimeData(const QModelIndexList &indexes) const

Umsetzt: ` QAbstractItemModel::mimeData(const QModelIndexList &indexes) const`.

Der Aufruf wird an das Quellmodell des ersten Indexes in der Liste von ` indexes` weitergeleitet.

Wichtig: Bitte beachten Sie, dass dieser Proxy nur das Ziehen einer einzelnen Zeile unterstützt. Er löst eine Assertion aus, wenn er mit Indizes aus mehreren Zeilen aufgerufen wird, da das Ziehen von Zeilen, die möglicherweise aus verschiedenen Quellmodellen stammen, von diesem Proxy-Modell nicht generisch implementiert werden kann. Jedes Datenelement in der ` QMimeData ` muss zusammengeführt werden, was datentypabhängig ist. Implementieren Sie diese Methode in einer Unterklasse neu, wenn Sie das Ziehen mehrerer Zeilen unterstützen möchten.

[override virtual] QStringList QConcatenateTablesProxyModel::mimeTypes() const

Implementiert neu: ` QAbstractItemModel::mimeTypes()` const.

Diese Methode gibt die MIME-Typen für das erste Quellmodell zurück.

[override virtual] QModelIndex QConcatenateTablesProxyModel::parent(const QModelIndex &index) const

Implementiert neu: ` QAbstractItemModel::parent(const QModelIndex &index) const`.

void QConcatenateTablesProxyModel::removeSourceModel(QAbstractItemModel *sourceModel)

Entfernt das Quellmodell „ sourceModel “, das zuvor diesem Proxy hinzugefügt wurde.

Die Eigentumsverhältnisse von sourceModel bleiben davon unberührt.

[override virtual, since 6.9.0] QHash<int, QByteArray> QConcatenateTablesProxyModel::roleNames() const

Implementiert neu: ` QAbstractItemModel::roleNames()` const.

Gibt die Vereinigung der `roleNames()` der zugrunde liegenden Modelle zurück.

Falls Quellmodelle derselben Rolle unterschiedliche Namen zuweisen, überschreibt der im letzten Quellmodell verwendete Name den in früheren Modellen verwendeten Namen.

Diese Funktion wurde in Qt 6.9.0 eingeführt.

[override virtual] int QConcatenateTablesProxyModel::rowCount(const QModelIndex &parent = QModelIndex()) const

Implementiert neu: ` QAbstractItemModel::rowCount(const QModelIndex &parent) const`.

[override virtual] bool QConcatenateTablesProxyModel::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)

Implementiert: ` QAbstractItemModel::setData` (const QModelIndex &index, const QVariant &value, int role).

Siehe auch data().

[override virtual] bool QConcatenateTablesProxyModel::setItemData(const QModelIndex &proxyIndex, const QMap<int, QVariant> &roles)

Implementiert: QAbstractItemModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles).

Siehe auch itemData().

QList<QAbstractItemModel *> QConcatenateTablesProxyModel::sourceModels() const

Gibt eine Liste der Modelle zurück, die als Quellmodelle für dieses Proxy-Modell hinzugefügt wurden.

[override virtual] QSize QConcatenateTablesProxyModel::span(const QModelIndex &index) const

Implementiert neu: ` QAbstractItemModel::span(const QModelIndex &index) const`.

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