title: Qt treewidget python; iterate columns
body: <p>Given a tree widget in PyQt4 with some rows and columns:</p>
  
  <p>1) Is there a way to easily iterate over all cells?</p>
  
  <p>2) How can one check if a checkbox is checked apart from the first column?</p>
  
  <p>So far I only managed to get the results of the checkboxes in the first column, see <a href="https://stackoverflow.com/questions/8961449/pyqt-qtreewidget-iterating">here</a>.</p>
  
  <p>For clarification here is the widget how I imagine it to look like: (the fourth column should be editable)</p>
  
  <p><a href="https://i.stack.imgur.com/qOzjM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qOzjM.png" alt="widget structure"></a></p>
  
  <pre><code>from PyQt4.QtCore import * 
  from PyQt4.QtGui import * 
  import sys
  
  
  def main(): 
      app     = QApplication (sys.argv)
      tree    = QTreeWidget ()
      item    = QTreeWidgetItem()
  
      tree.headerItem().setText(0, "col1")
      tree.headerItem().setText(1, "col2")
      tree.headerItem().setText(2, "col3")
      tree.headerItem().setText(3, "Notes")
  
      for ii in xrange(3):
          parent = QTreeWidgetItem(tree)
          parent.setText(0, "Parent {}".format(ii))
          parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
          for x in xrange(4):
              child = QTreeWidgetItem(parent)
              child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
              child.setText(0, "Child {}".format(x))
              child.setCheckState(0, Qt.Unchecked)
  
              #create the checkbox
              for i in xrange(1, 5):
                  if i &lt; 3:
                      child.setText(i, "")
                      child.setCheckState(i, Qt.Unchecked)
                  if i == 3:
                      child.setText(i, "Any Notes?")
                      child.setFlags(child.flags() | Qt.ItemIsEditable)
  
      tree.show() 
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>