That's because the following constructor is being used when you call QTreeWidgetItem(hdr, x):
*
*QTreeWidgetItem ( QTreeWidgetItem * parent, const QStringList & strings, int type = Type )

so it is treating your string as a list of strings. Since your column count is 1, you are only seeing the first character. You need to change your code as follows:

QTreeWidgetItem(hdr, [x])

-Selim

Jason Rahm wrote:

Here's my code:

            selected = None

            self.treeWidget_iRulesList.clear()

            self.treeWidget_iRulesList.setColumnCount(1)

            self.treeWidget_iRulesList.setHeaderLabels(["Rules"])

            self.treeWidget_iRulesList.setItemsExpandable(True)

            for item in allrules.keys():

                #print item

                hdr = QTreeWidgetItem(item)

                self.treeWidget_iRulesList.addTopLevelItem(hdr)

                self.treeWidget_iRulesList.expandItem(hdr)

                for x in allrules[item]:

                    #print x

                    rule = QTreeWidgetItem(hdr, x)

                    self.treeWidget_iRulesList.addTopLevelItem(rule)

If I uncomment my print statements, each string is printed as expected, but in the QTreeWidget, I only get the first character:

-g

----g

----t

----t

-l

----h

----u

----_

And so on.  Any ideas?  Thanks in advance.

Jason

------------------------------------------------------------------------

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

<<attachment: Selim_Tuvi.vcf>>

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to