I wanted to put the widgets relative to other widgets. For example, I can place the widget either right or left and either top or bottom of a widget. Something like that.
It sounds like you want something like "glue", which is used in another layout system the details of which I don't remember. "Interviews", maybe?

You can do this with grid, horizontal, vertical or a combination of layouts in a hierarchy. If you want to do this dynamically at runtime, then you need a way to specify the locations of widgets relative to each other, and build up the layouts to reflect that relationship. So if you have two widgets that are located top and bottom relative to each other, you create a a vertical layout, insert the top widget then the bottom widget.

If you don't want the widgets to expand their sizes or spacings as the container widget resizes, then insert horizontal or vertical spacers into the layouts.