PDA

View Full Version : Container choice problem



ZikO
17th September 2012, 12:56
Hi,

I need someone's advice.

I need to store somewhere a set of items, objects of QStandardItem, that are in a model, a QStandardItemModel. I need to store both items and their coordinates in a model. Essentially, in my application, a user can choose a few rows from a QTableView and make changes to a model. I synced a form and a Viewer with the same model so all changes should be updated immediately in the Viewer--QTableView.
However, I would like to have a functionality that all changes can be cancelled. Therefore, I would need to store somewhere original content of those records that have been changed. I could make a copy of the whole model and operate on its copy but this would not be very memory efficient. I thought I could utilize any of the Qt containers but I am not expert and I really don't know which container or even combination to choose. I would basically need to store a content of a particular item along with its coordinates. I would need something like this:

Container<QtStandardItem, QModelIndex>

The only problem is I don't know which container would be best for it or perhaps I'd better made my own class.

I hope I've been clear with the explanation.

Robbie
17th September 2012, 18:09
Have you had a look at the QDataWidgetMapper class? Looking at your attachments, this might be your answer and you won't have to worry about the inner structure of your data model.

ZikO
18th September 2012, 00:08
Hi Robbie,

Thanks. I read, not everything but quite a lot, about Model/View approach but did not come across this mapper. It will help me a lot :)

Thanks