Qt - How to control the widget sizes in QLayout

后端 未结 4 923
名媛妹妹
名媛妹妹 2021-01-15 08:12

I am trying to put some spinboxes,line edits in a layout. But the size extends more than the neccesity. Below is the figure

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-15 08:54

    In my opinion, working with stretch factors is not the right solution, here. It's a bit "hackish". Stretch factors are useful e.g. when you have two widgets that both use as much space as possible, but not at a 50:50 rate.

    Here, as I see it, you have two widgets (or groups of widgets), where one should only use as much space as it really needs and the other one should take the rest. That is what size policies are for. Set the horizontal policy of the left one to Expanding (or MinimumExpanding if you want to prevent scroll bars) and the right one to Preferred.

提交回复
热议问题