Display data from two SQL Tables with QTreeView
-
Hello,
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?Best regards,
Nicolae Rosia. -
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