Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] Growing a Rectangle "leftwards" or "upwards"
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!
Jens last edited by
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.
Great idea, Jens. Thanks!