PDA

View Full Version : QSortFilterProxyModel disables mouse clicking



tvj4218
14th November 2017, 22:42
I've subclassed QSortFilterProxyModel to sort QTreeView. This works fine except when I click on various rows/columns
of child items in the QTreeView, the clicks are not processed anymore.

I say anymore because if I take out the sorting code and not use the custom class, the clicks are processed correctly.

Any ideas?

Sorry, cannot post the code as it is part of a bigger project.

n

d_stranz
15th November 2017, 05:48
Any ideas?

If you are calling QTreeView::setModel() with the proxy model -after- calling QTreeView::setSelectionModel(), the selection model will be replaced with the tree view's default selection model. Reverse the order in which the two methods are called.

You must also ensure that the QTreeView and QItemSelectionModel are both using the proxy as their source models.

tvj4218
15th November 2017, 17:09
I’ve solved this issue, but I’m running into another issue.

When I click on a child entry in my tree view, the clicked signal for the tree view sends in the parent’s model index rather than the index of the child that was clicked on. I know this because when I try to get the child data I end up getting the parent data.

Any idea what’s going on?

d_stranz
16th November 2017, 16:00
Any idea what’s going on?

Why don't you try using the debugger to track what is happening? None of us here are very good at diagnosing code problem when there is no code to diagnose.