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.viewScaleX = 1.0
            self.viewScaleY = 1.0
        def setCorners(self, p1, p0=None):
            if p0 == None:
                p0 = self.pos()
            rect = rectThroughPoints(p0, p1)
            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

  • Lifetime Qt Champion


    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 :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.