您可以使用QLayout.setContentsMargins:# layout is a defined VBox or HBox layout.setContentsMargins(left, top, right, bottom)