DAG (Directed acyclic graph) - QAbstractItemModel

2019-03-01 13:31发布

问题:

I am planning on creating a Node Graph in pyqt. The abstract models that qt provides work for 1D, 2D and Tree data but the abstract class seems to break down for something like a node graph.

In particular the "parent" function in QAbstractModel returns QModelIndex of a single parent. In a DAG I will may have multiple parents.

One resource I found was this blog post:

http://invalidmagic.wordpress.com/2009/12/10/qgraphicsscene-used-as-a-qabstractitemmodel/

It provides some useful information, but I can't seem figure how the model represents the concept of multiple parents.

I'm looking for examples and suggestions for how to implement a DAG model in Qt.

回答1:

This thread entitled QTreeView display of graph (multiple parents of item) is an interesting resource that you can consider (It also addresses using QAbstractItemModel for the case).