PDA

View Full Version : QGraphicsScene doesn't return items at point



russiankid
7th April 2013, 01:21
I am trying to subclass QGraphicsScene so I can have faster hover detection than checking whether mouse coordinates are in the shape() of the QGraphicsItem, since my QGraphicsItem subclasses are easy to compute mouse distance to.

So far I have:

void myScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
qDebug()<<"pos list";
qDebug()<<items(event->pos(),Qt::IntersectsItemBoundingRect,Qt::Descendin gOrder);
qDebug()<<"rect list";
qDebug()<<items(this->itemsBoundingRect());
QGraphicsScene::mouseMoveEvent(event);
}

Since my QGraphicsItem subclasses have code for hover already, emitting the mouseMoveEvent triggers their hover as normal. The rect list lists all the items on the scene as expected, but the pos list is always empty. What could be causing this?

EDIT: needed event->scenePos(), solved