PDA

View Full Version : QAbstractItemView with subordinate QGraphicsView: Tracking index to graphics item



ChrisW67
12th October 2010, 05:22
I wish to allow users to select a set of geographical areas from a list/tree or by clicking on a map overlaid with tiles representing the areas. The idea is that the list/tree and map should share the same base model and selection model and stay nicely synchronised.

I read here (http://www.qtcentre.org/threads/26169-QGraphicsView-inside-of-QAbstractItemView-viewport) and the sage advise of Wysota to use a bare QGraphicsScene to render into the viewport of the QAbstractItemView. The gist of this is working although it is far from pretty at this point.

I am looking for advice on how to store connection between a model index and its matching QGraphicsItem. Model indexes themselves are quite fragile and, while I could use the index's internal pointer as an opaque key, I wonder if there is not some 'proper' method that I am missing.