PDA

View Full Version : Advice on best way to link drawing and tree



enricong
4th May 2012, 16:36
I have a data table which includes coordinate values which correspond with associated properties.
I plan to have a QGraphicsScene where circles are drawn based on each coordinate value.
Then, I also wish to have a QTreeView/Widget next to it with a branch for each coordinate/circle.

When the user clicks on a specific circle, I would like the QTree to select the corresponding entry.
When the user clicks on the specific QTree item, I'd like the corresponding circle to be highlighted

I can think of two ways to do this:
1. as I read the table, and start drawing circles and populate the tree, link each coordinate - circle pair using signal/slots for each
2. create a data structure saving the pointer to the circles and tree items. Setup one signal/slot, passing an ID value, the lookup the pointers in the data structure.

I'd appreciate any other ideas on the best way to do this.
Thanks

alecail
4th May 2012, 23:13
Hi,

Look at the "Chart" example included in the Qt SQK. The behaviour is really close to what you are describing. However it does not use a QGraphicsView to render the charts. It is also using the Model-View-Controller design pattern, so you are probably required to understand it first if you are not familar with it.