Hi.
I put the data into my QTableWidget tableView using a loop:
Qt Code:
  1. for i in range(0, len(res)):
  2. self.tableView.setItem(i, 2, QTableWidgetItem(str(create_dataframe(res)[2][i])))
  3. self.tableView.setItem(i, 3, QTableWidgetItem(str(create_dataframe(res)[3][i])))
To copy to clipboard, switch view to plain text mode 
where
Qt Code:
  1. create_dataframe(res)[2][i]
To copy to clipboard, switch view to plain text mode 
returns value of class 'int' and
Qt Code:
  1. create_dataframe(res)[3][i]
To copy to clipboard, switch view to plain text mode 
returns value of class 'datetime.datetime' (like '2017-03-25 16:51:24'). The question is: how do I make this items properly sortable through
Qt Code:
  1. self.tableView.setSortingEnabled(True)
To copy to clipboard, switch view to plain text mode 
, i.e. not as strings, but as integers and datetime respectively? I know that I should use setData and Qt.DisplayRole, but could you please give an example using this short piece of code?
Thank you.