I'm writing an app that reads and shows data from web server in QTableView/QTableWidget. Each entry will have several columns and also SetData to hold hidden information (from UI) in each entry (QVariant).
Point is, content of QTableView/QTableWidget changes based on what user choose from a ListBox, so everytime ListBox choice changes, all entries inQTableView/QTableWidget will be cleared and items related to it will be shown.
I want to cache all entries of Listbox items user click, so if user return back to same item, just show previous entries in QTableView/QTableWidget without again sending request to webserver to get content.
What's the best way to cache data to show in QTableView/QTableWidget?
1) Using QTableView and dynamically creating QAbstractTableModel, then keeping QAbstractTableModels in an array. So everytime user changes item in Listbox, I'll just call setModel on related TableModel item. Is it possible? If so how?
2) Using QTableWidget, then using something like hashmap to store all data for each listbox choice, then when user switches between items, clear QTableWidget and loop through map and add items each time?