PDA

View Full Version : Custom tree view suggestions



jtourville
6th May 2009, 20:44
I've got a project where I'd like to display a time line of events to the user, and I'd like something similar to a tree view since the events need to be categorized. Here is a mockup of what I'm thinking:

http://img7.imageshack.us/img7/3181/timelinek.png
http://img7.imageshack.us/img7/3181/timelinek.png

My question is: what is the best way to get something like those blue bars in the picture? What seems tricky to me is the blue bars (or whatever) need to span multiple columns. They also would obviously need to scroll with the view contents, and I need them to be selectable separately from the rest of the row, or at least be able to detect when a user clicks one.

From looking at example code, I can do custom drawing in paintEvent, but what I'm having trouble wrapping my head around is how to determine the coordinates of where the tree nodes and columns are so I can draw those boxes in the right place.

I have done a good bit of Qt programming in general, but I have zero experience with custom drawing.

Any suggestions are appreciated!

aamer4yu
6th May 2009, 23:00
Have a lookat delegates.. they are used for custom drawing on trees and lists, etc
You will need to override QItemDelegate::paint

jtourville
7th May 2009, 03:23
Have a lookat delegates.. they are used for custom drawing on trees and lists, etc
You will need to override QItemDelegate::paint

Thanks, I will look into that!