开发者

Set QBoxLayout maximum size?

I clearly missing something here, please enlighten me.

AttributeError: 'QVBoxLayout' object has no attribute 'setMaximumSize'开发者_C百科

I've been reading the Qt Docs for a while but just cant seem to be able to get this to work


AFAIK you can't set a maximal size for a layout. Why would you want to - it makes no sense to me (which child widget should the layout limit?)

Regarding setMaximumSize - there's no such method for layouts. There is however, a QLayout::SetMaximumSize constraint which you can set, but this constraint applies to the widget that's laid out with this layout, not to the layout itself. It means that the widget can grow no larger than the maximal size of the layout - so this is quite different from what you need.

I recommend you re-think your real goal - perhaps it can be achieved in some other way. For instance, you can set the maximal size for the individual widgets laid out by your QBoxLayout.


You cannot set the maximumSize property directly as it is dynamically determined by the layout. Perhaps you are trying to set the QLayout.SizeConstraint to QLayout.SetMaximumSize? If so, then see the QLayout.setSizeConstraint method. Otherwise, you should call QWidget.setMaximumSize if you want to specify an exact maximum for a given widget.


Just as that error tells you, there is no setMaximumSize method on a layout.

QWidgets have that method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜