title: Unable to grab the item on click in TreeView PyQt4?
body: <p>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. When I click the string/item in the treeview it shows this:
  <strong>PyQt4.QtCore.QModelIndex object at 0xb6b6c7d4</strong>
  instead of 
  <strong>Linux</strong></p>
  
  <pre><code>import sys
  from PyQt4.QtCore import *
  from PyQt4.QtGui import *
  from PyQt4 import QtCore, QtGui
  
  data = root = [
  
      ("Linux", [
  
          ("System",
  
                  [("System name",[]),
           ("Kernel", []),
           ("Drivers", []),
           ("Memory", []),
           ("Processes", []),
                   ("Disk mounted", []), 
           ("Services Running", []),
           ("Installed Packages", [])]),
          #[("System name", [])]),
  
          ("Network",
          [("Nework confi.",[]),
          ("Interface test", [])]),
  
          ("PCI Devices",
          [("PCI devices", [])]),
  
          ("Logs", 
          [("Messages",[]),
          ("Dmesg", [])]),
  
  
          ])]
  
  class Window(QWidget):
  
      def __init__(self):
  
          QWidget.__init__(self)
  
          self.treeView = QTreeView()
  
  
          self.model = QStandardItemModel()
          self.addItems(self.model, data)
          self.treeView.setModel(self.model)
  
          self.model.setHorizontalHeaderLabels([self.tr("Object")])
  
          layout = QVBoxLayout()
          layout.addWidget(self.treeView)
          self.setLayout(layout)
      self.treeView.connect(self.treeView, QtCore.SIGNAL('clicked(QModelIndex)'), self.treefunction)
  
      def treefunction(self, index):
      print index
  
  
      def addItems(self, parent, elements):
  
          for text, children in elements:
              item = QStandardItem(text)
              parent.appendRow(item)
              if children:
                  self.addItems(item, children)
  if __name__ == "__main__":
  
      app = QApplication(sys.argv)
      window = Window()
      window.show()
      sys.exit(app.exec_())
  </code></pre>