我有一个向导页面,其中显示两个表和一个手满的按钮。我的部分桌子滚动条和底部按钮一直处于隐藏状态,到达该页面时我必须扩大窗口。我不确定此页面的总体布局方案是否设置不正确。
如何在布局中调整布局和窗口小部件以及窗口的大小?
我在Python 3.7上使用PySide2。我已经尝试将布局设置为固定大小,并同时读取了其他一些线程,但是我似乎无法重现相同的结果,以使窗口小部件适合窗口内/当窗口调整大小时会随窗口缩放。>
class Resolution_Page(QtWidgets.QWizardPage):
def __init__(self, parent=None):
super(Resolution_Page, self).__init__(parent)
self.Resolution_Wizard_Page = QtWidgets.QWizardPage()
self.Resolution_Wizard_Page.setObjectName("Resolution_Wizard_Page")
self.ResolutionTable = QtWidgets.QTableWidget()
self.ResolutionTable.setObjectName('ResolutionTable')
self.SearchTable = QtWidgets.QTableWidget()
self.SearchTable.setObjectName('SearchTable')
self.SearchTable.setColumnCount(2)
self.SearchTable.setHorizontalHeaderLabels(['Searched Field', 'Searched Value'])
self.SearchTable.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
self.SearchTable.setSortingEnabled(False)
self.SearchTable.setEnabled(True)
self.SearchTable.setRowCount(0)
self.next_resolution_button = QtWidgets.QPushButton('Next Resolution')
self.next_resolution_button.setObjectName('next_resolution_button')
self.next_resolution_button.setMaximumWidth(200)
self.next_search_button = QtWidgets.QPushButton('Next Page')
self.next_search_button.setObjectName('next_search_button')
self.resolve_button = QtWidgets.QPushButton('Resolve Selection')
self.resolve_button.setEnabled(False)
self.resolve_button.setObjectName('resolve_button')
self.Search = QtWidgets.QPushButton('Search')
self.Search.setObjectName('Search')
self.previous_search_result_button = QtWidgets.QPushButton('Previous Page')
self.previous_search_result_button.setObjectName('previous_search_result_button')
self.previous_resolution_button = QtWidgets.QPushButton('Previous Resolution')
self.previous_resolution_button.setObjectName('previous_resolution_button')
self.previous_resolution_button.setMaximumWidth(200)
self.SearchTable.setMinimumWidth(300)
layout = QtWidgets.QWidget(self)
root_layout = QtWidgets.QVBoxLayout(layout)
central_tables = QtWidgets.QHBoxLayout()
middle_buttons = QtWidgets.QVBoxLayout()
bottom_buttons = QtWidgets.QHBoxLayout()
middle_buttons.addWidget(self.previous_search_result_button)
middle_buttons.addWidget(self.Search)
middle_buttons.addWidget(self.next_search_button)
central_tables.addWidget(self.SearchTable, stretch=1)
central_tables.addLayout(middle_buttons)
central_tables.addWidget(self.ResolutionTable, stretch=1)
bottom_buttons.addWidget(self.previous_resolution_button)
bottom_buttons.addWidget(self.resolve_button)
bottom_buttons.addWidget(self.next_resolution_button)
bottom_buttons.setAlignment(QtCore.Qt.AlignBottom)
root_layout.addLayout(central_tables)
root_layout.addLayout(bottom_buttons)
layout.setFixedSize(1200,600)
答案 0 :(得分:0)
您应该将顶部窗口小部件作为主布局的父级,并防止对主窗口小部件使用固定大小
main_layout = QtWidgets.QVBoxLayout(self)
#layout = QtWidgets.QWidget(self)
layout = QtWidgets.QWidget()
main_layout.addWidget(layout)
layout.setFixedSize(1200,600)