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
    Feb 2009
    Posts
    38
    Thanks
    29
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

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

    Quote Originally Posted by wysota View Post
    You mean you don't want to make it possible to scale the child to such size that it would become larger than its parent, right? In that case reimplement QGraphicsItem::itemChange() for your item. There you can check the newly set size and compare it with the parent's. Finally you can return the new size for your item which will be bounded to the parent size.
    First , I' m sorry, I' m a newer to this forum, and I don't know where to commit my question.

    Yes,you are right, now when I use QGraphicsItem::scale or QGraphicsView::scale,that only scale the viewport ,that's not what I wanted.
    And I don't catch your mean for i don't know how to use QGraphicsItem::itemChange() to signal it's size change to it's parent item. Should I use QGraphicsItem::ItemTransformHasChanged or QGraphicsItem::ItemPositionChange
    as a parameter of QGraphicsItem::itemChange() ?
    As I'm a newer to qt, so wish your reply again!
    Thank you!
    And could you provide me with source code on this ! Thank you very much!

  2. #2
    Join Date
    Aug 2008
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Hi christina123y,
    Can please give some code example or snippet.
    Thank you.

  3. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

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

    Have you had a look at QWT

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

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

    Quote Originally Posted by christina123y View Post
    And I don't catch your mean for i don't know how to use QGraphicsItem::itemChange() to signal it's size change to it's parent item. Should I use QGraphicsItem::ItemTransformHasChanged or QGraphicsItem::ItemPositionChange
    as a parameter of QGraphicsItem::itemChange() ?
    Use ItemTransformChange so that you can return a new transformation.

    And could you provide me with source code on this ! Thank you very much!
    There is a nice example in the itemChange() documentation, only that it monitors the position and not the transformation of the item.
    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.


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

    christina123y (27th February 2009)

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

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

    Quote Originally Posted by wysota View Post
    Use ItemTransformChange so that you can return a new transformation.



    There is a nice example in the itemChange() documentation, only that it monitors the position and not the transformation of the item.
    Ok, Thanks!
    I'll try my best to work out it!
    Any question countered, I'll share in!

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.