It's better to switch to the model approach sooner than later, you'll have less rewriting to do
For the beginning you can cheat a little, use QStandardItemModel and either create a custom item role which will hold a pointer to a graphicsview item or reimplement the index() method of the model and store the pointer as the internal pointer. The latter solution is better, but it'll only work if QStandardItemModel doesn't use that internal field for itself.
The point is that you don't want to do simple things, so you shouldn't use simple solutions.Also I need a tree with single column, so I am not sure to go in for a model for this... there must be a simple way
Does it matter? You only store there what you like.I cud have used this approach, but not all treeWidgetItems are related to GraphicsItem, like the PL.. it contains a list of graphicsitems which are contained in it.
That's another argument for using a full featured model.Also in future I may need to add tree nodes based on certain lists and not graphicsitems..
When I find some tme (during Christmas maybe?) I'll post an example model made from scratch on my website (in the GL model article series), so you'll be able to take a look.Also I would be glad if u teach me something about the model , model/view architecture in context with this prpblem, I searched thru Qt Examples but cudnt find a suitable example related to my problem.. only if experts like u speak something, it wud be a great speed up for guys like me![]()
Bookmarks