Make QHorizontalLayout expand inside QFrame

谁说胖子不能爱 提交于 2019-12-11 11:18:22

问题


I have a widget hierarchy like this, with a frame (in order to set a background color behind the buttons and label) and a horizontal layout as its direct child.

However, the horizontal layout (red frame in below screenshot of Qt Designer) does not take up the whole space inside the frame. How can I do that? Changing the property "layoutSizeConstraint" does not work. The label is already set to "Expanding" in horizontal direction, but still it keeps its size – I can resize the horizontal layout manually, but it should fill the width automatically.


回答1:


Your frame frame doesn't have a layout (it's shown on its icon in the tree). It's because you have added new QHBoxLayout and dragged it into a frame. You should remove this layout, drag the label and buttons to the frame, then open frame's context menu and choose "Layout" option and choose desired layout.



来源:https://stackoverflow.com/questions/17342316/make-qhorizontallayout-expand-inside-qframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!