Is there anyway to detect which mouse button was clicked from inside a QItemSelectionModel?
I want to block a right mouse click from changing the selection.
I am using this was a QTreeWidget, so if there is a way to mask the whole thing, that would be great, but the right-click is still used for context menus, so I didn’t pursue this avenue of thought.
Still trying things… I stumbled upon this but I haven’t been able to get the function to run: http://qt-project.org/faq/answer/how_to_prevent_right_mouse_click_selection_for_a_qtreewidget
This implies a simple override, but this didn’t work in Python
def mousePressEvent(self, mouse_event):
super(MyTreeWidget, self).mousePressEvent(mouse_event)
print "here %s" % event.type()
This feels like yet another workaround, but I got it working. In this example, the SelectionModel is also an event filter that is getting mouse click events from a QTreeWidget’s viewport()
Also see:
(Hopefully I didn’t leave anything out as I hacked this down on-the-fly, and my real implementation is a little more complex, and uses a separate event filter.)