[PyQt] selecting an item in qtreewidget
Jason Rahm
J.Rahm at F5.com
Wed May 4 12:19:35 BST 2011
That was it, thank you! I did have to add an int in the item.text(0) to do away with a not enough arguments error. So thankful for all the helpful people on this list. What a great community.
Jason
-----Original Message-----
From: pyqt-bounces at riverbankcomputing.com [mailto:pyqt-bounces at riverbankcomputing.com] On Behalf Of David Boddie
Sent: Tuesday, May 03, 2011 6:46 PM
To: pyqt at riverbankcomputing.com
Subject: Re: [PyQt] selecting an item in qtreewidget
On Tue, 3 May 2011 22:19:27 +0000, Jason Rahm wrote:
> One more thing, how do I pass the value of the clicked item to the
> displayRule def? Printing test gets the GUI components figured out,
> but not functional. Thanks in advance.
The itemClicked signal passes two parameters which you can receive in the method you connect the signal to.
def __init__(self):
self.treeWidget_iRulesList.itemClicked.connect(self.displayRule)
def displayRule(self, item, column):
self.textEdit_ScriptCanvas.clear()
self.textEdit_ScriptCanvas.setText('test ' + item.text() + ' column ' +
str(column))
> Still not sure about auto-selecting the last item added to the tree.
> Any thoughts would be appreciated.
You could call the tree widget's setCurrentItem() method, passing the last item. Whether the item will be selected, as well as made the current item, depends on what the selection mode is. You can change that by calling
setSelectionMode() with the required value:
http://doc.qt.nokia.com/4.6/qabstractitemview.html#SelectionMode-enum
David
_______________________________________________
PyQt mailing list PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
More information about the PyQt
mailing list