View Full Version : Embed rows of icons in a QTreeView?

17th July 2010, 02:03
Hey I'm wondering what is the best way to go about something with a QTreeView. I have a treeview where some of the items contain "regular" lists of things, but others contain a bunch of icons, kind of like a IconView.

These can't each be on their own line like, otherwise Treeview would support it easily. Here's a mockup of more or less what it should look like:

(those would just be regular QIcons -- they happen to be chopped from screenshots of a 3d view but they are not 3d or anything)

What do you Qt experts think the best way of doing this would be? It would be nice if the icons behaved like the rest of the items in the model, but I would be OK with just having one big item that embedded an icon view somehow..

Any advice? :confused: Or examples of similar code out there?


17th July 2010, 09:36
This is perfectly possible and actually not that difficult, although it takes a little bit of code.

You need to create a custom delegate and implement the paint and sizehint functions.
Using some event filters too, you can make it so that you can select one single item too.

Try creating such a delegate yourself. If you get stuck or don't know how to proceed, post the code you have so far and I or someone else will help you out.