qt - Select QGraphicsItem -


i have problems selecting qgraphicsitem.

i have multiple items (line , ellipse) , itemgroups (containing lines). in cases overlaying each other still visible because of transparency.

for example: first create small circle , later create bigger circle around small one.

how can select small circle?

i want item beeing selected if click on visible nontransparent part of (maybe tolerance lines of 1px width). how can that?

a small example how create circle:

circletodraw = new qgraphicsellipseitem; this->additem(circletodraw); circletodraw->setpen(qpen(qt::black, 1, qt::solidline)); circletodraw->setpos(origpoint); circletodraw->setrect(origpoint.y() - event->scenepos().y(), origpoint.y() - event->scenepos().y(), (event->scenepos().y() - origpoint.y())*2, (event->scenepos().y() - origpoint.y())*2); 

later implement qimages transparent parts. here problem again, want select items under transparent part.

thank you!

edit

my code now:

qlist<qgraphicsitem *> items = this->items(event->scenepos()); each(qgraphicsitem* item in items) {     if(item->opacity() == 1){     //opacity() not work expected     //circle still deleted when click (transparent) inside of         //item->setselected(true); //selects items while pressing mouse, top item after releasing mouse. why?         this->removeitem(item);         delete(item);     } } 


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -