Reimplement QGraphicsPathItem 's boundingRect() & shape() ?



  • i subclass a QGraphicsPathItem for custom lines and curves, as there are the control points for the curve which is out of the curve itself, and i wannt to dynamically click and move the control points, so i have to reimplement QGraphicsPathItem 's boundingRect() & shape().
    Now, (1) shape(): QPainterPath path = QGraphicsPathItem::shape(), then path.addRect() //add all the control points.
    (2) boundingRect(): QRectF rect = QGraphicsPathItem::boundingRect(), then rect = rect.united() //add all the control points.
    I debugged the shape() method seems work fine, BUT the boundingRect() method NOT RIGHT, after i click and move the controls point to another poisition. is it because the rect.united() i used?
    thank you!



  • can i simply return this->scene()->sceneRect() in the boudingRect()?
    i don't want to do like this cause my scene will be very large.
    but while i tested, it works fine, even while the lines and curves overlapped..



  • anyone met this kinda of problem?
    thanks:)



  • anyone help?
    thank you!


Log in to reply
 

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