[PyQt] selecting an item in qtreewidget
david at boddie.org.uk
Wed May 4 00:45:47 BST 2011
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 displayRule(self, item, column):
self.textEdit_ScriptCanvas.setText('test ' + item.text() + ' 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:
More information about the PyQt