Custom abstract class as a model in model/view architecture



  • Hello,
    In the most of the examples I saw about the use of the model/view architecture, there is a QList of
    some custom class as a member of the model, representing the data structure of the model.
    In my situation, this custom class is an abstract class and my data structure is
    a list of pointers to the instances of the abstract class.
    Since each instance will be a element of a derived class from the abstract class, the meaning
    of the 'rows' in the model will change depending on the instance.
    My question is if the model/view architecture is doable in this context or if it can lead to some
    pitfalls.

    Thanks in beforehand and sorry if I'm not very clear, I'm still a beginner in MVC architecture
    and English is not my motherlanguage.



  • As long as you know how to determine a row, this should be doable.



  • Besides needing to know what consitutes a row in your model, the items in your model also need to support some kind of interface that the model can use to query for the information it needs, like the string value or an icon or perhaps other relevant data.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.