开发者

QTreeWidget with multiple columns limits number of child items

开发者 https://www.devze.com 2023-03-08 05:54 出处:网络
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:

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:

QTreeWidget with multiple columns limits number of child items

However, if I change the column count,

treeWidget.setColumnCount(10)

I now get my children clipped after 6 levels

QTreeWidget with multiple columns limits number of child items

Many thanks!

Phil

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号