def hoverEnterEvent(self, event): if self.parentItem().isSelected(): self.parentItem().setSelected(False) if self.keepRatio: self.setCursor(qt.QCursor(qt.Qt.SizeFDiagCursor)) else: self.setCursor(qt.QCursor(qt.Qt.SizeAllCursor)) self.setBrush(qt.QBrush(qt.Qt.yellow, qt.Qt.SolidPattern)) return qt.QGraphicsRectItem.hoverEnterEvent(self, event)
def hoverLeaveEvent(self, event): self.setCursor(qt.QCursor(qt.Qt.ArrowCursor)) pen = qt.QPen() color = qt.QColor(qt.Qt.white) color.setAlpha(0) pen.setColor(color) pen.setStyle(qt.Qt.NoPen) self.setPen(pen) self.setBrush(color) return qt.QGraphicsRectItem.hoverLeaveEvent(self, event)