Hi,<div><br></div><div>i am having problems wrapping my head around on how to modify a model of a Qtree i have set up. my model consists out of a few children under root and each child has some children of it's own. to start of with i followed the simpleTreeModel example and got to the stage where my model gets correctly displayed. what i would like to do now is with a button trigger an update to the model and only displaying one of the items for example.</div>
<div><br></div><div>here are part of my codes. but really it's based on the simpleTreeExample</div><div><br></div><div><div>class TreeModel(QtCore.QAbstractItemModel):</div><div> def __init__(self, data, parent=None):</div>
<div> QtCore.QAbstractItemModel.__init__(self, parent)</div><div><br></div><div> rootData = []</div><div> rootData.append(QtCore.QVariant("Object"))</div><div> rootData.append(QtCore.QVariant("File 1"))</div>
<div> rootData.append(QtCore.QVariant("File 2"))</div><div> self.rootItem = TreeItem(rootData)</div><div> self.setupModelData(data, self.rootItem)</div><div><br></div><div>..............</div>
<div>.</div><div>.</div><div>.</div><div><br></div><div><div>def data(self, index, role):</div><div> if not index.isValid():</div><div> return QtCore.QVariant()</div><div><br></div><div> if role != QtCore.Qt.DisplayRole:</div>
<div> return QtCore.QVariant()</div><div><br></div><div> item = index.internalPointer()</div><div><br></div><div> return QtCore.QVariant(item.data(index.column()))</div><div><br></div><div>..</div>
<div>..</div><div>..</div><div><div>def setupModelData(self, data, parent):</div><div> parents = []</div><div> parents.append(parent)</div><div> for object in sorted(data.keys()):</div><div> columnData = []</div>
<div> columnData.append(object)</div><div> columnData.append(data[object][0])</div><div> columnData.append(data[object][1])</div><div> </div><div> adbItem = TreeItem(columnData, parents[-1])</div>
<div> parents[-1].appendChild(adbItem)</div><div> for each in data[object][2][0].keys():</div><div> columnData = []</div><div> columnData.append(each)</div><div> columnData.append(data[object][2][0][each])</div>
<div> columnData.append(data[object][2][1][each])</div><div> adbItem.appendChild(TreeItem(columnData, adbItem))</div><div><br></div><div>thanks in advance</div><div><br></div><div>sven</div></div>
</div></div>