HowTo resize Subclasses of QGraphicsItem



  • HowTo resize Subclasses of QGraphicsItem?



  • maybe by using the prepareGeometryChange in your overrided method resize and then setting the new QSizeF , the update is then done automatically, maybe forcing it will not hurt



  • You can use update() function this should do the job.
    void QGraphicsItem::update ( const QRectF & rect = QRectF() )
    it can be done calling prepareGeometryChange() with boundingRect(), I hope it should do the job ( I have never tested this though)



  • Assuming you mean "How do I create a resize-able custom QGraphicsItem?", the subclass needs to handle the mouse events to process a press-move-release sequence as a resize operation. During the operation, call prepareGeometryChange() and change the value which will be returned by the boundingRect().



  • [quote author="Bradley" date="1293081440"]Assuming you mean "How do I create a resize-able custom QGraphicsItem?", the subclass needs to handle the mouse events to process a press-move-release sequence as a resize operation. During the operation, call prepareGeometryChange() and change the value which will be returned by the boundingRect().[/quote]

    Well. This change the bounding rect of item. But the size of content is still the same. I need to resize content too within the new bounding rectangle.

    Thx.



  • Yes, I was assuming that the custom item was painting its contents relative to the size of the bounding rectangle.


Log in to reply
 

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