I am creating an app with three different tableviews that are on three tabs. All three tables have a “join” field that could be used to connect them. I brought in the tables from pandas using the very useful tutorial on the subject (https://www.learnpyqt.com/courses/model-views/qtableview-modelviews-numpy-pandas/). I want my script to automatically select rows in the other tables (based on the common field) if I select a row in the third table.
How would I programmatically select multiple rows given their indices? I want to select rows from one table automatically when I select rows from the other table.
Here is a link to my repository for those who are curious: https://github.com/inkenbrandt/wqxsde
Here is my best attempt to do what I am asking about, but it only appears to select one row in the other table, and not all the rows with a matching field:
def stationsel(self,s): self.stationselection = self.StationTableView.selectionModel() indexes = self.stationselection.selectedRows(column=2) df = self.ResultModel._data role = Qt.DisplayRole dg = df[df['monitoringlocationid'].isin([self.StationModel.data(i, role) for i in indexes])] print(dg) mode = QItemSelectionModel.Select | QtCore.QItemSelectionModel.Rows for i in dg.index: self.ResultTableView.selectRow(i) #for i in dg.index: # self.ResultTableView.selectRow(i)
This is the closest thing I can find in Stack Exchange: