Question

I am working on python plugins.I used PYQT4 designer for the forms. I am listing my query result into QTreeWidget as shown below:

     items = []
     for row in c.fetchall():

          item = QTreeWidgetItem()
          item.setText(0,unicode (row[0]))
          items.append(item)

 self.treeWidget.insertTopLevelItems(0, items)

Items are listed perfectly into the QTreeWidget.

enter image description here

But i wanted to make some items as parent like: EX:

ACO_010

-2
-1
-7 and so on...

How do i set any item as parent (root) of other items.??? I tried

self.treeWidget.__init__ (self,valestimate,items, int type = self.treeWidget.Type)

but no success.How do i set parent in QTreeWidget??.

Was it helpful?

Solution

Use parentItem.addChild(childItem)

(see the QTreeWidgetItem documentation)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top