I am trying to grab the string/object from the treeview. So when a user click on any item in the treeview, I can show it on the terminal. ANy help is appreciated.Here is the code.

QtCore.QObject.connect(self.treeWidget, QtCore.SIGNAL("clicked(QModelIndex)"), self.treefunction)

def treefunction(self, index):
    print index

Output on clicking the item in treeview is:

<PyQt4.QtCore.QModelIndex object at 0x8835a74>

Instead of the actual string.

You are getting the memory adress of object.

class Foo(object):
    def bar(self):
        return 'Hello'

Test class.

>>> obj = Foo()
>>> print obj
<__main__.Foo object at 0x0356B110>
>>> print obj.bar
<bound method Foo.bar of <__main__.Foo object at 0x0356B110>>
>>> print obj.bar()

As you see until a make correct call i get memory adress of object at 0x......
You can try something like index(), index.method_name, index.method_name().

I figured it out:

def treefunction(self, index):

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.