Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Display data from two SQL Tables with QTreeView
nicolae.rosia last edited by
I am trying to create a model based on QAbstractItemModel to be used with QTreeView in order to display data contained in two SQL tables. The first table, Table1, has the rowId as primary key. The second table, Table2, has also a primary key and another field as foreign key which references Table1(rowId).
As far as I understand, QAbstractItemModel::index returns an QModelIndex into which I embed data (internalPointer()) which I later use when QAbstractItemModel::data and QAbstractItemModel::parent are called.
The problem is that the dataset is huge hence I cannot cache it and I would like to cache only the rows that are visible. Is there any way to know which rows are visible ?
How would you approach this problem?
Santosh Reddy last edited by
Use two QSqlTableModels inside your custom QAbstractItemModel, and I don't think you need worry about cacheing the rows yourself, it will be taken care by QSqlTableModels