Results 1 to 12 of 12

Thread: How to scale an object which inherit QGrahicsItem within it's parent QGraphicsItem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to scale an object which inherit QGrahicsItem within it's parent QGraphicsIte

    You're using the wrong change value. I said ItemTransformChange not ItemTransformHasChanged.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    christina123y (2nd March 2009)

  3. #2
    Join Date
    Feb 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    29

    Default Re: How to scale an object which inherit QGrahicsItem within it's parent QGraphicsIte

    Quote Originally Posted by wysota View Post
    You're using the wrong change value. I said ItemTransformChange not ItemTransformHasChanged.
    here is my code :
    Qt Code:
    1. QVariant draw2dgraph::itemChange(GraphicsItemChange change, const QVariant &value)
    2. {
    3. if(ItemTransformChange == change && parentItem() )
    4. {
    5. QTransform trans = transform();
    6. QRectF rect = trans.mapRect(boudingRect());
    7. if(parentItem()->boundingRect().size()!=rect.size())
    8. {
    9. rect = parentItem()->boundingRect();
    10. }
    11. }
    12. return QGraphicsItem::itemChange(change,value);
    13. }
    To copy to clipboard, switch view to plain text mode 

    but the draw2DGraph's object still outside it's parent boundingRect after it zoom in.
    In draw2DGraph class I do zoom in function like this
    Qt Code:
    1. void draw2DGraph::zoomIn()
    2. {
    3. scale(1.2,1.2);
    4. }
    To copy to clipboard, switch view to plain text mode 
    why ? why still happen like this? wish you help again! Thank you
    Last edited by wysota; 6th March 2009 at 22:08. Reason: missing [code] tags

  4. #3
    Join Date
    Feb 2009
    Posts
    38
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    29

    Default Re: How to scale an object which inherit QGrahicsItem within it's parent QGraphicsIte

    Quote Originally Posted by wysota View Post
    You're using the wrong change value. I said ItemTransformChange not ItemTransformHasChanged.
    Can you help me? This problem has troubled me almost a week, I really need help? And I have look up reference on internet, but resolvation on this problem is so little. So I really need your help! Could you please provide me with some demo or sources on this problem!Thank you very much!

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to scale an object which inherit QGrahicsItem within it's parent QGraphicsIte

    You have to map your size to your parent's coordinate space (or vice versa) based on the transform you get as the argument. This will allow you to compare your rectangle and the rectangle of your parent. Then you'll be able to correct the matrix based on the comparison (by scaling it back down).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.