I have 3 comboboxes and a QTableView widget with 3 columns. I want to filter each of these columns by selected option in combobox connected to it. I know how to do it for just one column with setFilterKeyColumn()
method, but how to achieve the same result for more comboboxes? I obviously want all the filters to be active at the same time.
This is my example for 1 connected column
self.cb1 = QComboBox()
self.cb2 = QComboBox()
self.cb3 = QComboBox()
model = QStandardItemModel(5, 3)
# skipped the model populating code
filter_proxy_model = QSortFilterProxyModel()
filter_proxy_model.setSourceModel(model)
filter_proxy_model.setFilterKeyColumn(1)
self.cb1.currentTextChanged.connect(filter_proxy_model.setFilterFixedString)
table = QTableView()
table.setModel(filter_proxy_model)