Hi,
I have a list of dictionaires. Something like that:
The issue is the indexing shown in the code below. The way it is done there, would work for a nested list (list of a list) ... but how to do it, if you have to deall with dictionaries which are nested in a list ...?
I have a list of dictionaires. Something like that:
addressbook = [] address_1 = {"city": "Berlin", street": "Alexanderplatz"} address_2 = {"city": "Munich", street": "Stachus"} ... addressbook.append(address_1) addressbook.append(address_2) ...Now, I want to display that list of dictionaries in a QTableView-Widget. That Widget, will get the data from the below sub-classed QAbstractTableModel my_TableModel.
The issue is the indexing shown in the code below. The way it is done there, would work for a nested list (list of a list) ... but how to do it, if you have to deall with dictionaries which are nested in a list ...?
class my_TableModel(QtCore.QAbstractTableModel): def __init__(self, my_data): super(my_TableModel, self).__init__() self._my_data = my_data def data(self, index, role): if role == Qt.ItemDataRole.DisplayRole: return self._my_data[index.row()][index.column()] # <<--- this is not working for dictionairies nested in a list !!! def rowCount(self, index): return len(self._my_data) def columnCount(self, index):anzupassen return len(self._entgeltpunkte[0])For any kinds of tips and hints, I would be very gratefull! Thanks in advance!!!