0
这让我有点疯狂。希望有人能为我解决这个问题。运行以下代码会导致第一个打印语句是一个包含QVBoxLayout
对象的元素的列表。我将两个对象设置为layout
为什么我只能得到一个?pyQt QLayout问题
第二个打印语句给出两个对象QHBoxLayout
和QPushButton
。是不是QPushButton
是layout
的子女?
我希望layout.children()
给我两个对象QPushButton
和QVBoxLayout
和self.children()
给我一个对象QHBoxLayout
。我错过了什么?
from PySide.QtGui import *
import sys
class Main(QWidget):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
layout = QHBoxLayout(self)
layout.addWidget(QPushButton("foo"))
layout.addLayout(QVBoxLayout())
print layout.children()
print self.children()
app = QApplication([])
main = Main()
main.show()
sys.exit(app.exec_())
看起来像PySide的文档是缺乏一点。感谢您的链接。 – Jeff 2012-02-18 04:44:54