I have a subclass of QGraphicsRectItem. The mouseMoveEvent handler looks like this:
void BTNodeGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
QGraphicsRectItem::mouseMoveEvent(event);
qDebug() << rect().x() << " " << rect().y();
}
The item drags like I expect. But the qDebug statement outputs the same coordinates as I drag it. Shouldn’t the rect be changing as it is dragged?
You are getting the position in coordinates that are relative to the graphics item. To get coordinates in another perspective, use something like
mapToScene(rect())