December 8, 2010

Bradley Bradley
Lab Rat
314 posts

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?

 Signature 

Nokia Certified Qt Specialist.

10 replies

December 8, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts
Bradley wrote:
Is it possible to have a visible QGraphicsItem with no location?

items belonging to a scene and which are visible, will have a location i.e. a geometry

Bradley wrote:
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?

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 …

December 8, 2010

GordonSchumacher GordonSchuma..
Lab Rat
93 posts

Why do you want to do this? Perhaps there’s a different way to accomplish it.

December 8, 2010

Bradley Bradley
Lab Rat
314 posts

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.

 Signature 

Nokia Certified Qt Specialist.

December 8, 2010

Bradley Bradley
Lab Rat
314 posts
chetankjain wrote:
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 …

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.

 Signature 

Nokia Certified Qt Specialist.

December 8, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts
Bradley wrote:
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.

ah ok, in that case I think you have to extend QGraphicsScene, reimplement items() to do what you want

December 8, 2010

GordonSchumacher GordonSchuma..
Lab Rat
93 posts

Not necessarily; see also this message [lists.trolltech.com] from the mailing list.

December 8, 2010

Bradley Bradley
Lab Rat
314 posts

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.

 Signature 

Nokia Certified Qt Specialist.

December 9, 2010

GordonSchumacher GordonSchuma..
Lab Rat
93 posts

Hm. I think I’m missing something; why do they need to be in the same scene?

December 9, 2010

Bradley Bradley
Lab Rat
314 posts

The some interaction with other items in the scene.

 Signature 

Nokia Certified Qt Specialist.

December 10, 2010

GordonSchumacher GordonSchuma..
Lab Rat
93 posts

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.

 
  ‹‹ "Special Items" in QMenu      My USB mouse freezing after any QT application run ››

You must log in to post a reply. Not a member yet? Register here!