Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
frame won't stretch in vbox layout
I have a simple form using a vertical box layout, containing two frames. Each frame has a vertical box layout of its own, and contains a QTableWidget. The top table widget has a maximum height set. Here's a picture:
I expect the bottom table widget to expand to fill the form, but it doesn't. I have not found any combination of size policies on the frames and table widgets that will make this work.
I've posted the form .ui file here:
When i try your UI files, the lower frame follows the dialog just fine.
They split the size 50/50 as instructed.
What is the goal ?
you want the lower frame to take up most space so the top one is only the fixed size you have set on it ?
@mrjj yes I want the bottom frame to take up the extra space. Why is it only splitting 50/50? I have the vertical stretch factors set to zero everywhere.
0,0 means split equally.
you want something like else
I don't think that is the right answer. There is no point in having the QVBoxLayout if I have to manage the sizes myself by adjusting the stretch factors.
If I set the minimum height on the upper frame instead of the widget inside it, then I get the desired result. Why isn't the upper QFrame passing on size as the size of its contents?
Im not sure what you mean. the stretch factor adjusts the space allocated to each widget and you need only to set this once to specify how it should be shared.
well layouts like to share the space so if entire dialog leaves more space then it will use it.
@mrjj so how do I specify that either frame should use as much space as possible?
There may be scenarios where the bottom table has a maximum height instead, so I can't just set a stretch of 0,1.
As I said, it works when I put the maximum height on the frame instead of the table widget inside the frame. I don't understand why the frame isn't shrinking itself to the size of the table widget and then the other frame gets the extra space.
I don't understand why the frame isn't shrinking itself to the size of the table widget and then the other frame gets the extra space.
Because, by default, all QFrames try to expand to get a share of the available space.
If you want the frame to shrink to its contents, set the frame's Size Policy to Maximum.