def paint(self, painter, option, widget): rec = self.boundingRect() self.blackPen = QtGui.QPen(QtCore.Qt.black) self.blackPen.setWidth(0) painter.setPen(self.blackPen) painter.fillRect(rec, self.brush) painter.drawRect(rec)
def paint(self, painter, option, widget): rec = self.boundingRect() blackPen = QtGui.QPen(QtCore.Qt.transparent) blackPen.setWidth(0) blackPen.setStyle(QtCore.Qt.DotLine) painter.setPen(blackPen) flags = self.flags() if flags & QtWidgets.QGraphicsItem.ItemIsMovable: blackPen = QtGui.QPen(QtCore.Qt.black) blackPen.setWidth(0) blackPen.setStyle(QtCore.Qt.DotLine) painter.setPen(blackPen) if self.isSelected(): blackPen = QtGui.QPen(QtCore.Qt.white) blackPen.setWidth(0) blackPen.setStyle(QtCore.Qt.DotLine) painter.setPen(blackPen) painter.fillRect(rec, self.brush) painter.drawRect(rec)