My data is loaded from an XML file, and is certainly hierarchical. Adapting the data to work with Qt's Model/View framework seems to be straight forward. However, the XML nodes are not primitive objects, like numbers or strings. I like to display the data similar to the Simple Widget Mapper example. I have a form with some labels, a text field, buttons, maybe check boxes. Furthermore, items in the hierarchy view can be selected (e.g. checking check boxes), removed (close button), edited (edit button), dragged and dropped. Drag and Drop is used to manipulate (insert, move, copy) the hierarchy. What is the best practice?
So far, I see three Options:
Use QDataWidgetMapper with nested widgets:
The attributes of an XML node are listed in a single row. For each node a QDataWidgetMapper is associated with that row. The QDataWidgetMapper synchronizes the widget fields with the appropriate node values. All events, drag, and drop, selection, ... must be handled by the widgets. Widgets provide drop containers. The nested widgets represent the data hierarchy.
Implement a custom QAbstractItemView, and use delegates:
I am aiming for something like a Nassi-Shneiderman diagram. Therefore, the standard QTreeView cannot be applied. However, it should be possible to create a basic hierarchic layout inheriting QAbstractItemView. A custom delegate is used, to paint the XML data with the form widgets, and create the editors. The QAbstractItemView is responsible for drag, drop, managing the selection model, (somehow) listening to button events to remove items from the hierarchy, and to ask the delegate for an editor.
Something else:
I am far away from being a Qt guru. I welcome suggestions.
Which option is recommended? Which option do you consider less painful?
EDIT - February 21st: Does someone know, how Qt Designer is implemented? This is pretty much, what I am looking for. As in Qt Designer, I have elements (loops, conditions, actions, ...), and like to edit hierarchic processes. Some elements are containers, others are leafs. Some elements are structured horizontally, others vertically. Is Qt Designer a QGraphicsScene?
Thank you for your help, and suggestions, Marian