Reputation: 339
As a follow-up to my previous question, which was solved, I now want to make the items selectable. As mentioned earlier, I activated all kinds of selection-related parameters in the view and I also return core.Qt.ItemIsSelectable
in the flags
-method of the model. But still option.state & gui.QStyle.State_Selected
is never fullfilled. Any help is highly appreciated. Please also note the minimal example in the linked question.
Upvotes: 0
Views: 740
Reputation: 339
I solved it myself. The problem was, that the custom QStyledItemDelegate catches the mouse event, so that it is not passed to the QListView. So in the QStyledItemDelegate.editor(Event)
one simply needs to add
if event.type() == core.QEvent.MouseButtonPress:
return False
Now the selection is detectable in the paint()
-method using option.state & gui.QStyle.State_Selected
.
Upvotes: 2