Is it possible to have a visible QGraphicsItem with no location?
-
With QGraphicsScene, is there any way to have items in the scene which will not be returned by items(QPoint) and still visible in the scene?
-
[quote author="Bradley" date="1291827845"]Is it possible to have a visible QGraphicsItem with no location?[/quote]
items belonging to a scene and which are visible, will have a location i.e. a geometry
[quote author="Bradley" date="1291827845"]With QGraphicsScene, is there any way to have items in the scene which will not be returned by items(QPoint) and still visible in the scene?[/quote]
you are interested in the items(QPoint) call, so you can probably check the different options available for Qt::ItemSelectionMode and see if something suits you
items that are not located at this point, are of course still visible and will not be returned with items(QPoint) call ... -
Why do you want to do this? Perhaps there's a different way to accomplish it.
-
I have a QGraphicsView which does certain actions based the items in the scene (for example re-framing the view to center and zoom on certain items). However, the scene also contains heads-up-display (HUD) items which must be ignored. Currently I'm filtering the HUD items when re-framing. I'm wondering if there is a more creative solution.
-
[quote author="chetankjain" date="1291830853"]you are interested in the items(QPoint) call, so you can probably check the different options available for Qt::ItemSelectionMode and see if something suits you
items that are not located at this point, are of course still visible and will not be returned with items(QPoint) call ...
[/quote]I don't see an Qt::ItemSelectionMode that would apply, since I want to create an special item that would not be selected even though some other regular item at the same location would be.
-
[quote author="Bradley" date="1291836670"]
I don't see an Qt::ItemSelectionMode that would apply, since I want to create an special item that would not be selected even though some other regular item at the same location would be.
[/quote]ah ok, in that case I think you have to extend QGraphicsScene, reimplement items() to do what you want
-
Not necessarily; see also "this message":http://lists.trolltech.com/pipermail/qt-interest/2010-March/020837.html from the mailing list.
-
A transparent overlay widget would then mean the items are not in the scene. I guess reimplementing items() or filtering the results from items() is all I can do.
-
Hm. I think I'm missing something; why do they need to be in the same scene?
-
The some interaction with other items in the scene.
-
I suspect you're right then, and those are your best options. A fast way to do the filtering (however it's done) might be to check QGraphicsItem::type() - or better (if you can), make all the HUD objects children of a single item and set QGraphicsItem::ItemHasNoContents on that parent item. That way (I think) you'd only have one QGraphicsItem to check.