[Interest] QGraphicsItem and QPointer analog

Igor Mironchik igor.mironchik at gmail.com
Tue Feb 16 09:57:51 CET 2016


Hi folks,

Let's say you need a group and some move/resize handles for this group 
(I'm talking about QGraphicsView). Such handles can't be children of the 
group because then they won't receive any mouse events. So you have to 
set parent of such handles to group's parent.

Easy? Yes!

But it's not easy to correct destroy of such handles if you allow user 
to select group and delete it. On such deletion you have to delete 
handles of the group too.

It's possible to do, but in very old C++ style, even C style :)

It would be much more better to have something similar to QPointer but 
for QGraphicsItem, i.e. QGraphicsPointer... With such technique you can 
check in dtor if handles was already removed (i.e. was normal 
destruction of the entire scene) and don't delete already deleted items, 
and you don't need to have something like destroyHandles() method of 
your group and on single deletion you don't need to invoke this method...

What do you think?



More information about the Interest mailing list