Qt-interest Archive, December 2006
best way to force a re-filter in a sort filter proxy model
Message 1 in thread
I have 1 model, representing a set of data, and then I have 2 proxy
models, one that shows the chosen data, and the other is the available
data.
My dialog (with 2 list views) owns the source Model, and it has 2
buttons. The user can select from the 1 list view, hit the add button,
and the item should show up in the second view. If they hit the remove
button, the item should remove it self from the second view, and show up
in the first.
In order to toggle, I have a slot on the button clicked, in the slot, I
get the selected items from the selectionModel for the appropriate view,
and call setData with a custom IsChosen role that sets the value to true
or false depending on if the add ore remove button has been clicked.
In the setData method, which is in the sourceModel, I do emit
dataChanged on the modelindex.
Everything works fine, EXCEPT, I seem to have to be responsible for
telling the proxy models that the source data has changed, and they
should remap their data.
One method, which was UGLY, is I call reset in the setData method. If I
call reset, I get a nasty flash to the two lists.
I was able to get rid of the flash, by calling clear on the proxy models
from the buttonClick slots, and it works, but it seems like the proxy
model should handle this for me.
Any ideas?
Scott