Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Advice on subclassing QAbstractItemModel



  • Hi,

    I have a data structure representing a processing pipeline, similar e.g. to the pipeline defined in the ITK library: process objects contains data objects as outputs which could then be referenced as inputs for another process object, etc.

    I am considering the QAbstractItemModel interface to benefits the model/view tools of Qt but I don't find a "good" way to index the objects of my pipeline. The way I see it is to index both the process and the data objects (and use the flags to specialize the options into the model): the QModelIndex corresponding to a process object would have children, each one corresponding to one of its outputs, and the QModelIndex of a data object would have children, each one corresponding to one of its "followers" (a process object referencing it as an input).

    The problem is that if a given process object has multiple inputs its QModelIndex would have multiple QModelIndex as parent, which looks not possible if I understand the documentation(?)

    Did anyone try to subclass QAbstractItemModel like this? Any advice would be greatly appreciated.


Log in to reply