This is the first application I have created with Python QT so apologies if I have missed something really fundamental.
The following table is populated via a QAbstractTableModel linked to a Pandas Framework. I have an PlayerIDX (e.g. 30, who in the example is running 25th) and want that row to be highlighted. At the moment I have the following function:
def highlight_player_row(self, row):
for column in range(0,self.columnCount()):
ix = self.index(row, column)
print(ix)
self.colors[(row, column)] = QBrush(Qt.darkCyan)
self.dataChanged.emit(ix, ix, (Qt.BackgroundRole,))
which called with highlight_player_row(30) results in the following:
Rather than row 24/31 being highlighted I would like row 30/25 (marked in yellow).
I don't know if it makes any difference but I am sorting the dataframe prior with:
self.idx_data = idx_df.sort_values(by=['CarIdxPosition'])
Do I need to go back to where the dataframe is formed from the incoming data and flagged?
IIUC, try
get_loc
to return the physical position of the sorted DataFrame's index :Or ignore the index when sorting and then
highlight_player_row(24)
: