@Christian-Ehrlicher said in QTableView with QAbstractTableModel derrived class not displaying data:
Elements
I don't see where you fill this container.
Sorry, I should have mentioned that Elements is being filled, and has been tested. I was originally using a QListView with QStringListModel which worked to show that Elements was being filled. When I switched to QTableView and QAbstractTableModel I had added a debug statement to rowCount() to also confirm that Elements was filled.
void RailDocModel::operator<<( LayoutObject * NewElement )
{
Elements << NewElement;
}
And here you're missing some important signals: https://doc.qt.io/qt-6/model-view-programming.html#inserting-and-removing-rows
That pointed me to what I was missing. Changing operator<<() to this was the solution:
void RailDocModel::operator<<( LayoutObject * NewElement )
{
beginInsertRows( QModelIndex(), Elements.count(), Elements.count() );
Elements << NewElement;
endInsertRows();
}
I had tried adding beginInsertRows() and endInsertRows() recently, but had used nullptr as the first parameter to beginInsertRows() instead of QModelIndex().