How to customize QTableView's columns which differ from model

27 views Asked by At

I use a model with a signature like this:

from PySide6.QtCore import QAbstractTableModel, Qt, QModelIndex

class PandasModel(QAbstractTableModel):
    """A model to interface a Qt view with pandas dataframe """

    def __init__(self, dataframe: pd.DataFrame, parent=None):
        QAbstractTableModel.__init__(self, parent)
        self._dataframe = dataframe

And (for clearness) I will store file paths in my dataframe. Let's call it Table1

index filename
0 01.jpg

But I want my table view to provide some read-only columns like file's abspath and size.Let's call it Table2

index filename abs path size
0 01.jpg D:/01.jpg 100KB

And I don't want to store extra info in Table2 in my disk, only data in Table1 is useful.

Can I custom the QTableView to do this? Or I will have to create 2 models?

0

There are 0 answers