Either have a global hash (or event two) to map between objects or have pointers to appropriate graphicsitems in tree items and vice-versa.
Either have a global hash (or event two) to map between objects or have pointers to appropriate graphicsitems in tree items and vice-versa.
ah yeah, youre right... a hash table should work.
But the other method (storing the pointers inside the items) sounds even better.
Lets say i derived a new Class "Node" from QGraphicsItem which stores a pointer to the corresponding QTreeWidgetItem. I find out my selected QGraphicsItem by calling view->scene()->selectedItems(), how can i get the stored pointer now? Because this function just returns me items of the base class QGraphicsItem.
What i could do, is to reimplement the setSelected function in my class "Node" and call the QTreeWidget::setCurrentItem() with the stored pointer from there. is that the way to go? cause it doesnt seem to work... isnt the QGraphicsView calling the setSelected() function on an Item, if you click on it in the view (its flag is set to QGraphicsItem::ItemIsSelectable)?
Last edited by Cal; 20th November 2009 at 14:01.
Since your have got 2 views that are reflecting the selection, is it not better to use a model, and manage some Ids for your items instead of pointers directly?
Then, each view cans have a map of [Id, item] to manage selection.
Bookmarks