TheMeaningfulEngineer
TheMeaningfulEngineer

Reputation: 16349

Is the Model View the right choice when the both have to be customized to fit the app need?

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):

enter image description here

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

Answers (1)

RobbieE
RobbieE

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

Related Questions