Qt4: Sorting QAbstractItemVew inherited view
Hi everybody,
i have a problem with sorting in my view:
i have implemented my own view (inherited from QAbstractItemView) and my own model (inherited from QAbstractItemModel) and my own Proxy (inherited from QSortFilterProxyModel).
Everything like inserting data, updating and removing data works fine.
Now i want to add sorting, so i reimplemented the proxy's lessThan method.
If i trigger a sort by calling:
pView->model()->sort(colIndex);
i see the proxy's lessThan method is called as expected,
but my view do not update (reorder) its contents.
If i connect a standard QTableView to my proxy and then enable sorting and then click on an cell-header,
i also see the proxy's lessThan method is called
and the table displays the reordered data correctly
so i think i have missed something in my own view implementation, but i don't know what?
Does somebody has done this already?
Greetings,
Nando
Re: Qt4: Sorting QAbstractItemVew inherited view
Have you reimplemented any other methods than lessThan in your proxy? Do you emit proper signals from the model? Does the view listen for them and refreshes itself according to their contents?
Re: Qt4: Sorting QAbstractItemVew inherited view
Hi,
i think my proxy is fine, because if i use my proxy with a standard QTableView,
then sorting works.
My model emits dataChanged signal and that works fine. So my view gets the updates.
I think maybe i have forgotten to overwrite some methods in my view.
I do not know which methods are called from the (proxy)model if sorting is in progress. dataChanged and currentChanged or rowsRemoved or rowsInserted aren't called.
Do i manually have to connect my view to some slots ?
I thought if i call pView->setModel(pProxy) all these connections are done implicitly (because inserting/removing and updating date works fine) ???
Greetings,
Nando
Re: Qt4: Sorting QAbstractItemVew inherited view
Hard to say without seeing any code. Maybe you are not connected to layoutChanged() or some other signal...