PDA

View Full Version : How do you get a child widget to resize with its parent?



Anduril28
24th August 2016, 16:19
I have two custom widgets: Graph and Paint, I want to overlay the Paint widget on the Graph widget.

I've made Paint a child of Graph and I have a layout assigned to the MainWindow; This works like I want it to until I change the size of the main window, the Graph adjusts, but Paint does not (see Figure 1). If I add a layout to the parent Graph as well then Paint ends up in the corner and still doesn't stretch appropriately (see Figure 2).

I've been looking around, but haven't been able to find out how to adjust this, I would prefer a method of fixing it in the designer if possible. Thank you!

Figure 1:
12092

Figure 2:
12093

anda_skoa
24th August 2016, 17:02
If you have no layout, then you need to resize manually.

If you have a layout, the widget needs to tell the layout that it can expand.
See the widget's sizePolicy property.

Cheers,
_