[Solved] Growing a Rectangle "leftwards" or "upwards"


  • Moderators

    Hi all,

    My large window contains a medium-sized Rectangle in the middle. This Rectangle contains several small graphical items in arbitrary positions. I'd like to change the size of this outer Rectangle without affecting the global position of the inner items.

    To grow/shrink the right and bottom edges, I just have to change the width/height properties. How do I grow/shrink the left and top edges though?

    I suppose I can do something like:

    Increase the outer Rectangle's width by x pixels

    Move the outer Rectangle to the left by x pixels

    Move every inner item to the right by x pixels

    ...but that seems like an expensive way to do it. Is there a cleaner way?

    Thanks in advance!



  • You can introduce an intermediate content Item between the outer rectangle (viewport?) and the children. Then all you have to do is to modify the x value of the content item by x pixels and the children will all follow.


  • Moderators

    Great idea, Jens. Thanks!


Log in to reply
 

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