[PyQt] selecting an item in qtreewidget

Jason Rahm J.Rahm at F5.com
Tue May 3 20:27:15 BST 2011

Newbie question...I'm stuck on how to select an item in my qtreewidget.  This loop populates my tree:

        item = []
        for item in allrules.keys():
            hdr = QTreeWidgetItem([item])
            x = []
            for x in allrules[item]:
                rule = QTreeWidgetItem(hdr, [x])


This is where I'm trying to set the current item, but I'm guessing it's empty since there isn't one already set?

        selRule = self.treeWidget_iRulesList.currentItem()

How do I select the last item added, and how do I select one by clicking on it?  Sorry to be so basic, I'm really trying to understand the syntax!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110503/2f2339c1/attachment.html>

More information about the PyQt mailing list