这让我有点疯狂。希望有人能帮我弄清楚。运行以下代码将导致第一个print语句是一个包含一个元素的列表QVBoxLayout
对象。我将两个对象设置为layout
为什么我只得到一个?在
第二个print语句给出了两个对象QHBoxLayout
和{QPushButton
不是layout
的孩子吗?在
我希望layout.children()
给我两个对象QPushButton
和{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_())
我想来自documentation的注释已经足够清楚地解释了这一点:
相关问题 更多 >
编程相关推荐