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:
{
qDebug()<<"pos list";
qDebug()<<items(event->pos(),Qt::IntersectsItemBoundingRect,Qt::DescendingOrder);
qDebug()<<"rect list";
qDebug()<<items(this->itemsBoundingRect());
}
void myScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
qDebug()<<"pos list";
qDebug()<<items(event->pos(),Qt::IntersectsItemBoundingRect,Qt::DescendingOrder);
qDebug()<<"rect list";
qDebug()<<items(this->itemsBoundingRect());
QGraphicsScene::mouseMoveEvent(event);
}
To copy to clipboard, switch view to plain text mode
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
Bookmarks