I am working on python plugins.I used QTreeWidget to list items.
[listing in qtreewidget][1] this link helped me a lot.
My code is:
valestimate=QTreeWidgetItem(str(parent_name))
for row in c.fetchall():
strval=QTreeWidgetItem(unicode(row[0]))
valestimate.addChild(strval)
self.treeWidget.addTopLevelItem((valestimate))
parent_name is name of my parent in QTreeWidget.
EX: ‘ACO_233’
But output is :
![enter image description here][2]
If i set columncount as more then one then it is shown as:
![enter image description here][3]
How do i list full string as parent in Qtreewidget??
following this link [single character in qtreewidget][4] ..inserttoplevelitem takes list as parameter..But if i want to make any item as parent ,we cannot add list to qtreewidget type item. How do i do it??
Check the documentation:
QTreeWidgetItemexpects a list of strings to fill in columns. When you doQTreeWidgetItem(str(parent_name))it interprets the stringparent_nameas a list of characters (which is what a string is) and puts every character in a column. Instead you should be doing:This will give you a single column item with
parent_nameas the value in that column.(By the way,
str()orunicode()is not a good way to convert things around. You should use.encodeto convertunicodeintostror.decodefor vice versa.)