Treeview for a sequence... it's worth to use a model?
-
I have to show a sequence of actions in a graphical form. The sequence is based upon a hierarchical structure, example:
Section 1 Group 1 Action 1 | Description | Progress | State Action 2 | Description | Progress | State Action 3 | Description | Progress | State Group 2 Action 1 | Description | Progress | State Action 2 | Description | Progress | State Action 3 | Description | Progress | State Section 2 Group 1 Action 1 | Description | Progress | State Action 2 | Description | Progress | State Action 3 | Description | Progress | State Group 2 Action 1 | Description | Progress | State Action 2 | Description | Progress | State Action 3 | Description | Progress | State
I think a treeview is the most suitable way to present this information.
As you can guess, each row is update one by one changing the progress and the state.
I would insert some customQWidget
in the cells, like progress bars, leds or any other stuff I need.I'm wondering if it's worth to use a model (and hence a
QTreeView
) for this use-case or it's easier to use aQTreeWidget
where each cell is manually updated.My thoughts: the second way is more handy to display custom widgets but requires more code. Instead the model-based approach is more robust but more limited (unless you want to deal with a lot of delegates).
Any other suggestion?
-
Hi,
Your custom model will give you more flexibility. You can more easily change the view on top of it.
As for your custom items in the cells: QStyledItemDelegate is the way to go.
-
@SGaist said in Treeview for a sequence... it's worth to use a model?:
As for your custom items in the cells: QStyledItemDelegate is the way to go.
As far as I understand, with
QStyledItemDelegate
I have to subclass thepaint()
event in order to draw something "custom", haven't I? I mean, it's not possible to just set aQWidget
and handle its signals/slots?I ask this because this way is quite simple with simple editors (like the start example of the Qt docs). But if you want to insert something more complex drawing everything manually in the
paint()
event doesn't seem so handy... -
You'll end up with hundreds or even more widgets which will kill performances.