title: Load Qtablewidget with a list
body: <p>I have a list like below</p>
  
  <pre><code>[('John', datetime.datetime(2019, 5, 5, 0, 54), datetime.datetime(2019, 5, 26, 22, 51, 36)),
  ('Rex', datetime.datetime(2019, 5, 26, 22, 51, 36), datetime.datetime(2019, 6, 15, 10, 22, 48)),
  ('Watson', datetime.datetime(2019, 6, 15, 10, 22, 48), datetime.datetime(2019, 7, 8, 13, 33, 36)), 
  ('Manila', datetime.datetime(2019, 7, 8, 13, 33, 36), datetime.datetime(2019, 7, 29, 6, 18)), 
  ('Pete', datetime.datetime(2019, 7, 29, 6, 18), datetime.datetime(2019, 8, 6, 18, 50, 24)), 
  ('Mathew', datetime.datetime(2019, 8, 6, 18, 50, 24), datetime.datetime(2019, 8, 31, 3, 14, 24))]
  </code></pre>
  
  <p>I have created a UI like below 
  <a href="https://i.stack.imgur.com/gtxzH.png" rel="nofollow noreferrer">Qtablewidget</a></p>
  
  <p>How can i add the Name in <code>Name</code> column, First date in <code>From</code> column and second date in <code>To</code> column. i tried <code>setitem</code> on push button click but it did not work</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  class Ui_MainWindow(object):
      import datetime
      def setupUi(self, MainWindow):
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(800, 600)
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName("centralwidget")
          self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
          self.tableWidget.setGeometry(QtCore.QRect(30, 90, 311, 301))
          self.tableWidget.setObjectName("tableWidget")
          self.tableWidget.setColumnCount(3)
          self.tableWidget.setRowCount(0)
          item = QtWidgets.QTableWidgetItem()
          self.tableWidget.setHorizontalHeaderItem(0, item)
          item = QtWidgets.QTableWidgetItem()
          self.tableWidget.setHorizontalHeaderItem(1, item)
          item = QtWidgets.QTableWidgetItem()
          self.tableWidget.setHorizontalHeaderItem(2, item)
          self.pushButton = QtWidgets.QPushButton(self.centralwidget)
          self.pushButton.setGeometry(QtCore.QRect(240, 430, 75, 23))
          self.pushButton.setObjectName("pushButton")
          MainWindow.setCentralWidget(self.centralwidget)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName("statusbar")
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          _translate = QtCore.QCoreApplication.translate
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
          item = self.tableWidget.horizontalHeaderItem(0)
          item.setText(_translate("MainWindow", "Name"))
          item = self.tableWidget.horizontalHeaderItem(1)
          item.setText(_translate("MainWindow", "From"))
          item = self.tableWidget.horizontalHeaderItem(2)
          item.setText(_translate("MainWindow", "To"))
          self.pushButton.setText(_translate("MainWindow", "Load"))
          self.pushButton.clicked.connect(self.onload)
      def onload(self):
          for i in mainlist:
              self.tableWidget.setItem(i[1])
  
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>How can i make this work</p>