我在用PySide设计窗口时遇到问题。在
class MainForm(QWidget):
def __init__(self, parent=None):
super(MainForm, self).__init__()
# init window
self.hbox = QHBoxLayout(self)
self.scroll = QScrollArea(self)
self.table = QTableWidget(self)
self.leftspltr = QSplitter(QtCore.Qt.Vertical)
self.rightspltr = QSplitter(QtCore.Qt.Vertical)
self.scroll.setWidget(self.leftspltr)
self.rightspltr.addWidget(self.table)
self.hbox.addWidget(self.leftspltr)
self.hbox.addWidget(self.rightspltr)
self.setWindowTitle("...")
self.table.setColumnCount(3)
self.table.move(11,220)
self.table.verticalHeader().hide()
self.table.setHorizontalHeaderLabels(["Key","Full","HR"])
dic = dumpered_hash.dict_naming_values
os.popen("rm dumpered_hash dumpered_hash.py dumpered_hash.pyc")
xpos = 0
ypos = 0
for key, val1 in sorted(dic.iteritems()):
btn = QPushButton(key, self)
btn.clicked.connect(partial(self.fillTbl, val1, len(val1) + 1))
btn.setFixedSize(84,20)
self.leftspltr.addWidget(btn)
滚动时im trying to design a window that has some button (more than 30) placed virtically, so I want to have them in scroll bar that fits the window size, and a table at the right side that doesn
t移动。
上面的代码给了我一个可以移动按钮的小滚动条,但是它们超出了窗口大小。在
怎么了?在
我想我理解你在这里想做什么。但是,您要将按钮放置在垂直拆分器中,然后调整其大小。相反,将按钮放置在垂直布局中,然后将其和表小部件放置到水平拆分器中。在
我还想指出的是,最好包含重现问题所需的最简单的代码片段。我不知道您试图用包含
dumpered_hash
的行来实现什么,但这似乎是不相关的,而且可疑地使用了一个不推荐使用的函数,这使得不经修改就无法运行代码。让人们更容易帮助你!在相关问题 更多 >
编程相关推荐