Could anyone help me understand the following behaviou开发者_如何学JAVAr? If I run this PyQt script I can generate a simple window with a QTreeView with multiple child items:
import sys
from PyQt4.QtGui import QApplication, QWidget, QTreeWidget, QTreeWidgetItem, QVBoxLayout
from PyQt4.QtCore import QStringList
app = QApplication(sys.argv)
win = QWidget()
win.resize(320, 240)
win.setWindowTitle("Hello, Overflowers!")
treeWidget = QTreeWidget()
treeWidget.setColumnCount(1)
def addChildWidgets(parent, depth=1):
child = QTreeWidgetItem(parent, QStringList([repr(depth)]*(depth+1)))
if (depth<12):
addChildWidgets(child, depth+1)
return child
item = QTreeWidgetItem(treeWidget, QStringList(["root"]))
addChildWidgets(item)
treeWidget.insertTopLevelItems(0, [item])
layout = QVBoxLayout()
layout.addWidget(treeWidget)
win.setLayout(layout)
win.show()
sys.exit(app.exec_())
I get the children I expect:
However, if I change the column count,
treeWidget.setColumnCount(10)
I now get my children clipped after 6 levels
Many thanks!
Phil
精彩评论