PDA

View Full Version : Group selection based on function contains() instead on bounding rectangle



SasaVilic
2nd November 2010, 19:54
I have two or more groups that overlaps, and I can not select the group which is beneath others. I made the group class by myself by extending QGraphicsItem, and implemented functionality: boudingRect - which returns union of all children's bounding rectangles, and function contains() that test if some of the children contains this points.

The goal is that if I click with mouse exactly on some child of group, this group will be selected. Otherwise pressing somewhere inside bounding rectangle of group, but not onchild, will not cause selection of group. This could be solution to problem above.

The problem is: the functions contains(QPointF) in never called. It seems like, that QGraphicsView is using another method to check if some graphicsitem is under mouse.

Do you have any other idea? Why function contains() is not called?