Zyend Zyend - 1 year ago 123
C++ Question

Implementing different views with Qt and QSortFilterProxyModel

I'm currently writing a prototype of an AVOD Portal application for embedded systems using Qt and QML.

Basically, I have a catalog of media (music, stream, movies etc.).
I plan to have different views of media according to the choice of the users:

  • viewing all the medias

  • viewing only the movie media

  • viewing only the music etc.

For that purpose, I plan to implement a
to implement my whole catalog.
And then, I plan to implement different
objects to filter the display accord the choice of the user (see. above).

I have been using MVC with Qt for a while but I never used the proxy-model.
So before getting into the code, I'm wondering if it is a reliable solution and if it fits with the integration of the models into QML ?


Answer Source

A proxy model is a model that happens to query other models behind the scenes. That a model is a proxy is an implementation detail invisible to the user of the model (e.g. to the view). There's nothing otherwise special about a model being a proxy from the model user's point of view. A proxy model is "just" a QAbstractItemModel with some convenience code added if you happen to derive from one of the proxy base classes.

In other words, there isn't much to a proxy model: it must fulfill all of the requirements placed on a QAbstractItemModel, because it is one.

So yes, your approach will work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download