Unable to make a simple selection rectangle by taking rect between two points.... all day!
class SelectionRect(QGraphicsRectItem): def __init__(self, scene, parent=None): QGraphicsRectItem.__init__(self, parent) self.setBrush(QBrush(Qt.NoBrush)) self.viewScaleX = 1.0 self.viewScaleY = 1.0 scene.addItem(self) self.setPen(self.createPen()) self.setVisible(False) self.setZValue(sys.float_info.max) def setCorners(self, p1, p0=None): if p0 == None: p0 = self.pos() rect = rectThroughPoints(p0, p1) self.setPos(rect.topLeft()) self.setRect(QRectF(0, 0, rect.width(), rect.height())) I use setCorners to position the selection rect every mouse move event in a qgraphicsscene. the behavior is it's working for everything but moving the edges of the selection rectangle up or left
@enjoysmath Found it, up or left self.pos() is no longer the appropriate corner
Glad you found out and thanks for sharing !
Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)