View Full Version : Can i share the same model for QtreeView and Qgraphics view......
sandyam
13th July 2011, 07:53
Actually i want to draw network topology view on QGraphicsView ,for that i have one explorer treeview on the right side of the window ,both topology view and treeview should be in synk.so can i share the same model between both views?
Santosh Reddy
13th July 2011, 08:20
You cannot have common model for QTreeView and QGraphicsView, even though both of these are based on same concepts (Model/View), but the these use a different set of model interface classes.
What you can do is, have a QTreeView connected to a QAbstractItemModel, and a QGraphicsView connected to QGraphicsScene, and then connect the QAbstractItemModel to QGraphicsView in the back-end. (You might have already figured this out, by now)
The connection between QAbstractItemModel and QGraphicsView is responsible in keeping then in sync, so using signals & slot mechanism should be good, rather than a interface class.
Also needless to mention you need use sub-class ofQAbstractItemMoel and sub-class of QGraphicsScen, as these base classes will not be sufficient to support the syncing functions
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.