Hi.
I put the data into my QTableWidget tableView using a loop:
for i in range(0, len(res)):
self.
tableView.
setItem(i,
2,
QTableWidgetItem(str
(create_dataframe
(res
)[2][i
]))) self.
tableView.
setItem(i,
3,
QTableWidgetItem(str
(create_dataframe
(res
)[3][i
])))
for i in range(0, len(res)):
self.tableView.setItem(i, 2, QTableWidgetItem(str(create_dataframe(res)[2][i])))
self.tableView.setItem(i, 3, QTableWidgetItem(str(create_dataframe(res)[3][i])))
To copy to clipboard, switch view to plain text mode
where
create_dataframe(res)[2][i]
create_dataframe(res)[2][i]
To copy to clipboard, switch view to plain text mode
returns value of class 'int' and
create_dataframe(res)[3][i]
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
self.tableView.setSortingEnabled(True)
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.
Bookmarks