def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent): if event.buttons() & Qt.LeftButton: rect = QRectF(event.buttonDownPos(Qt.LeftButton), event.pos()).normalized() self.__selection_rect.setRect(rect) self.__selection_rect.setVisible(True) if rect.width(): self.select(None) event.accept()
def mouseMoveEvent(self, event: QGraphicsSceneMouseEvent): if event.buttons() & Qt.LeftButton: if self._selection_rect is None: self._selection_rect = ViolinItem.SelectionRect( self, self._width, self._height) x = event.buttonDownPos(Qt.LeftButton).x() rect = QRectF(x, 0, event.pos().x() - x, self._height).normalized() rect = rect.intersected(self.contentsRect()) self._selection_rect.setRect(rect) event.accept()
def mousePressEvent(self, event: QGraphicsSceneMouseEvent): if event.buttons() & Qt.LeftButton: if event.modifiers() & Qt.ControlModifier: self.__sel_action = self.SelectAction.Toggle elif event.modifiers() & Qt.AltModifier: self.__sel_action = self.SelectAction.Deselect elif event.modifiers() & Qt.ShiftModifier: self.__sel_action = self.SelectAction.Select else: self.__sel_action = self.SelectAction.ClearSelect self.select(event.pos()) event.accept()