Cristhian Boujon
Cristhian Boujon

Reputation: 4190

Is Qt Model/View programming design pattern limited?

I'm reading about Model/View programming design pattern but I don't understand how to define a model. My model should inherit from QAbstractItemModel? If yes, I think it is very limited because my models class couldn't inherit from another model class.

Upvotes: 2

Views: 556

Answers (1)

Mat
Mat

Reputation: 206669

C++ has multiple inheritance, so technically your models could derive both from the Qt model base classes and something else.
That being said, multiple inheritance is rather tricky (for me anyway), composition is easier to get right.

One way of "merging" your ORM model classes with Qt's is to create a Qt model class that has one (or more) of your ORM's models as a member. The Qt model would essentially proxy all requests to your ORM model. The Qt model would be just an "adapter". This keeps your ORM code independent from the GUI toolkit, which is generally good.

Make sure you check out the Model subclassing reference for the Qt side of things.

Upvotes: 2

Related Questions