def mousePressEvent(self, event): if event.button() == Qt.RightButton: # Capture mouse press so that selection doesn't change # on right click pass else: QTreeView.mousePressEvent(self, event)
def mousePressEvent(self, event): # Inspired by http://stackoverflow.com/questions/2761284/is-it-possible-to-deselect-in-a-qtreeview-by-clicking-off-an-item # Get the index of item at click position index = self.indexAt(event.pos()) # If no item is clicked clear selection and reset index if not index.isValid(): self.clearSelection() self.setCurrentIndex(index) QTreeView.mousePressEvent(self, event)
def mousePressEvent(self, event): if event.type() == QEvent.MouseButtonPress: index = self.selectionModel().selectedIndexes() if self.on_right_click and event.button() == Qt.RightButton: if index: self.on_right_click(index[0]) return elif self.on_left_click and event.button() == Qt.LeftButton: QTreeView.mousePressEvent(self, event) index = self.selectionModel().selectedIndexes() if index: self.on_left_click(index[0]) return QTreeView.mousePressEvent(self, event)
def mousePressEvent(self, event): self.clearSelection() return QTreeView.mousePressEvent(self, event)
def mousePressEvent(self, event): if not self.indexAt(event.pos()).isValid(): self.clearSelection() QTreeView.mousePressEvent(self, event)
def mousePressEvent(self, e): self.clearSelection() QTreeView.mousePressEvent(self, e)
def mousePressEvent(self, event): if event.button() == Qt.RightButton: pass QTreeView.mousePressEvent(self, event)
def mousePressEvent(self, event): self.selectionModel().clear() QTreeView.mousePressEvent(self, event)