How to display one row of data in 2 lines of a QTableView
-
Hey everyone,
I have a line of data in my SQLite3 database table that looks like this:
Essentially it's right and left eye measurements.
I'd like to view them in a table like this:
Where the above would constitute one "row"Reading the documentation, this seems like a job for either QStyledItemDelegate, since its responsible for painting, or QTableView because it changes the indexes?
Any tips or recommendations would be greatly appreciated, thanks all.
EDIT: Or maybe I should subclass QAbstractTableModel:
class TableModel(QtCore.QAbstractTableModel): def __init__(self, data): super().__init__() self._data = data def data(self, index, role): if index % 2 == 0: # something here
-
Hi,
It would rather be option number 3: a proxy model that reassemble the data the way you want it.
-
I just realized that it would make things complicated for nothing.
Just implement a custom QStyledItemDelegate that draws the row entries the way you want to show them. Way simpler that rearranging the data as I suggested above.
You would use a QListView so your delegate can simply pull the row data when painting.