title: PyQt CheckBox checking in QTableWidget not working
body: <p>I'm trying to read the checkstate of checkboxes in a PyQt QTableWidget with python, but when I click the checkbox I see it changing, but my code doesn't. Here's the code I'm using. Any ideas?</p>
  
  <pre><code>class MyWindowClass(QtGui.QMainWindow, window):
      def __init__(self, parent=None):
          QtGui.QMainWindow.__init__(self, parent)
          self.load_table()
  
      def load_table(self):
          """Fill table with data from results"""
          self.todoTable.clear()
          result = [(0, "name", "Desc", "2014-12-07", "1"), (1, "name", "desc", "2014-12-08", "0")]
          self.todoTable.setRowCount(result.__len__())
          self.todoTable.setColumnCount(4)
          self.todoTable.setHorizontalHeaderLabels(["State", "Date", "Name", "Description"])
          for i in range(result.__len__()):
              self.todoTable.setItem(i, 2, QtGui.QTableWidgetItem(result[i][1]))
              self.todoTable.setItem(i, 3, QtGui.QTableWidgetItem(result[i][2]))
              self.todoTable.setItem(i, 1, QtGui.QTableWidgetItem(result[i][3].__str__()))
              checkItem = QtGui.QTableWidgetItem()
              if int(result[i][4]) == 2:
                  checkItem.setCheckState(QtCore.Qt.Checked)
                  checkItem.setText("")
              else:
                  checkItem.setCheckState(QtCore.Qt.Unchecked)
                  checkItem.setText("")
              self.todoTable.setItem(i, 0, checkItem)
          self.todoTable.resizeColumnsToContents()
          self.todoTable.itemChanged.connect(self.item_changed)
  
      def item_changed(self, item):
              row = item.row()
              state = item.checkState()
              print("Current state is: {}".format(state))
              print("we're now at item in row: {}".format(row))
              if state == 2:
                  print("set checked")
              elif state == 0:
                  print("set unchecked")
              else:
                  print("Something is not working fine here")
  </code></pre>
  
  <p><strong>Update:</strong> fixed the code, updated to reflect changes</p>