Reputation: 16349
I'm just starting with Qt and i'm having a doubt if the Model View is the right way to go here.
I have a following object which has to be persistent in some database:
Class Car:
{
private:
Qstring owner;
bool registered;
Qstring tires
}
The data should have the following view (it's a representation of a object Car):
My idea was to subclass the QAbstractItemView
and try to adopt it to the customized QAbstractItemModel
. The data is much better represented as objects than any of the default models mappings (list, table tree) which is why I can't see the benefits of using the Model View as shown in tutorial examples.
Would the model view be useful here, and what should the model/view costumization include?
Upvotes: 0
Views: 71
Reputation: 4350
You look like you're using standard QWidget
UI elements. These already exist so there's no need to create them again using a QAbstractItemView
. You can use the QtDesigner instead.
The Model-View pattern still applies though.
You can use the QStandardItemModel
or your own custom QAbstractTableModel
to handle the data storage and retrieval, and you can connect the UI with the model using the QDataWidgetMapper
Upvotes: 1