QAbstractItemModel, flags and a QTreeView
mcleary last edited by
When developing a QTreeView that need to change the flags (Qt::ItemFlags) for each item depending on the application state I encountered the following problem.
Suppose I select 5 items in the tree view. The event selectionChanged is emitted normally for the 5 items. The user then click in a button that will perform some processing on those items in the background. While the process is going on I would like to disable the selected items so the user cannot do anything with the 5 selected items.
To accomplish this I used the QAbstractItemModel::flags() method to return only the flag Qt::ItemIsSelectable. In the tree view the items are selected. But when I click in a new item the event selectionChanged doesn't inform that the previously selected items were deselected.
Is this Qt's normal behavior?
Do you mean that visually they are not selected anymore and not part of the deselected value from selectionChanged ?