Filter QTableView rows with QSortFilterProxyModel and ComboBox
-
Hello,
Its been two days that I'm trying to implement this thing, but can't figure it out.
I'm using Pyside2, python 3.8, Qt 5.
-
I have a
QTableView
with aQAbstractTableModel
to it. I have a Combobox (ComboBoxColumns) that lists all my columns headers, and a second Combobox (ComboBoxValues) that lists all the distinct values in the column that is selected in the ComboBoxColumns. My two ComboBoxs are connected to two different QStringListModel. -
What I want is to only keep the rows where the Value(row, ComboboxColumns.currentIndex) == ComboBoxValues.currentIndex.
I'm trying to implement a ProxyModel class from QSortFilterProxyModel, even after two days of reading documentations and other threads on StackOverflow, Qt Forum. I still have no clue on how to do it.
If someone can guide me through this, at least just to put me on the right rails, I'd be thankful.
Thanks;
-
-
Hi,
Wouldn't it be simpler to set the same model on your combox and set the appropriate model column based on your ComboBoxColumns selection ?
-
There's an example in the QSortFilterProxyModel documentation.