PDA

View Full Version : TreeView with staggered cells and widgets in row



JohnRoe
1st June 2015, 23:40
Hi,
I am trying to design a way to represent a tree like data structure that contains nodes/rows of different appearances. I attached an image of what I would like it to look like. Note: 'data' in the image means text and the tree structure is dynamic, i.e., users can add/remove nodes and change the type of a node.

What I am trying to get is a tree where each row contains all of its data together, that is that each piece of data in the row doesn't have to align with other row's data and isn't segregated by column. Additionally, rows don't all have to have the same number of columns or same type of data in each column. Furthermore, certain rows may contain bits of editable text and/or widgets (or an emulation of a widgets behavior/functionality).
11189

From other (http://www.qtcentre.org/threads/26916-inserting-custom-Widget-to-listview) posts (http://www.qtcentre.org/threads/30753-tree-view-displaying-widgets-as-items) it seems that the best way to go about handling widgets is just emulating them through a delegate. But what would be a good way to handle having cells in a column with inconsistent sizes and data types, and that certain rows have different number of columns?

The solution I have thought up is just having 1 column with everything in it and then having the delegate decide if user input landed on an interactable location (i.e. a widget). This way I can easily handle rows having a different number of columns and I don't have to come up with my own implementation of QTreeView. Although, determining when user input landed in one of those interactable locations may be hard/inefficient.

Before I begin the process of implementing this I just wanted to check if that sounds like a good solution, or if anyone knows a better way to handle something like this.

Thanks!

d_stranz
6th June 2015, 16:49
I can't think of a way to handle this except using the one-column-custom-delegate method you have proposed. The standard tree model / view likes things all lined up nice and neat.

I don't know what your application is for this, but it sounds like a pretty confusing interface for the user. Click somewhere, you can edit; click somewhere else and you can't edit, but it all just looks like text.