Solved Showing QTableModel on the QtableView in two columns
-
Hi there,
I want the QTableView to show the QTableModel's data in two vertical parts (set of columns) so that the left side shows records from the beginning of the model and the right side continues to show other records in the model. For example, there is a model with 15 records and a view with 10 rows. I want the view to show the first 10 rows in the left side, and the left 5 rows in the right side. How can I achieve this with QTableView.
Thanks in advance -
@mfaghani
QTableView
in itself is not going to do this. It shows rows from the data as rows on the screen.I would say: use some
QAbstractProxyModel
-derived class to map from the source model's rows with their columns to produce a new set of rows with twice as many columns, to correspond to the two sets of identical columns you wish to see. You should see what I mean.Having said that, it's a bit of an unusual request. Do you really need the two sets of columns to be in the same
QTableView
? It would be a lot easier to have twoQTableView
s touching each other side-by-side, each with their own filtered set of rows from the model...? -
Thank you JonB,
The QTableView I'm using is supposed to have row headers in different color on both sides. So using QAbstractProxyModel makes it even more complicated to implement, as you mentioned. I think, I will use two QTableView as you suggested.
Thank you very much