PDA

View Full Version : Custom QTreeWidgetItem with QSliders



nicole.cpp
25th August 2013, 16:32
I have a QTreeWidget, and I want to populate it with a list of items. Each item would be just a standard one sort of like this:

9481

(Sorry that these came out so small)


Ideally, upon clicking on the label ("Node 0" in this case), the item would expand to give an array of QSliders with a little set button, like this:


9482

As you might have guessed, this QTreeWidget is part of an interface that lets the user move objects around a scene. All interpretations aside, though, is this sort of customization feasible with QTreeWidgetItems (e.g., with setItemWidget)? Or do I need to use something like QTreeView?

Alternatively, if anyone knows of a good example of some sort of list structure filled with custom, dynamic widgets, please provide a link.

Santosh Reddy
26th August 2013, 08:46
All interpretations aside, though, is this sort of customization feasible with QTreeWidgetItems (e.g., with setItemWidget)? Or do I need to use something like QTreeView?
Yes it is possible using QTreeWidget, but it will trun out not be trival. Also the child widgets (the sliding bars) will be offset from the left when compared to the parent item. If you have multiple columns in the QTreeWidget then will have little more work to do.


Alternatively, if anyone knows of a good example of some sort of list structure filled with custom, dynamic widgets, please provide a link.
Well some more information is required to make good suggestions.
1. How many such "Node 0" are expeted (How many rows)?
2. Can they change from some background event, or only user can change them?
3. If some back ground event changed the slider values, do you need to update the slider values on scenn?

One suggestion which I can make with provided information is that QTreeWidget / QTreeView may not be required, if the interface is just to change the item position/orientation in the scene. You could just make a custom widget with sliders and edit the selected item in the scene.

wysota
26th August 2013, 10:37
Why not just use QScrollArea?

nicole.cpp
26th August 2013, 14:36
1. How many such "Node 0" are expeted (How many rows)?
2. Can they change from some background event, or only user can change them?
3. If some back ground event changed the slider values, do you need to update the slider values on scenn?
.

1. That depends on how many such "nodes" happen to be present in the scene. The user will load a scene with a map, which is made up of 0 or more nodes and/or edges.
2. Only the user can edit the node locations/orientations through this menu (at least as I envision it now).
3. Probably not applicable due to 2., but in such an event, yes.

This might make things a little more clear. The entire widget for editing nodes looks like this. The upper scroll area is the one I'm concerned with now:

9483