Hi,
I'm trying to get the position of the origin point of a graphics item (myFirstItem) relative to another graphics item (mySecondItem) using Qt 4. From reading the documentation, it looks like mapToItem() should do this for me, specifically:

QPointF QGraphicsItem::mapToItem ( const QGraphicsItem * item, const QPointF & point ) const

I attempted to implement this as follows:

Qt Code:
  1. QPointF getRelativeOrigin(QGraphicsItem *myFirstItem, QGraphicsItem *mySecondItem)
  2. {
  3. QPointF *centrePoint;
  4. QPointF relativePoint;
  5.  
  6. centrePoint = new QPointF(0.0, 0.0);
  7. relativePoint = myFirstItem->mapToItem (mySecondItem, centrePoint);
  8. return relativePoint;
  9. }
To copy to clipboard, switch view to plain text mode 

It seems to assume a different interface to the method mapToItem() then I expect as the following errors are returned when I build:

demo.cpp: In member function ‘QPointF demo::getRelativeOrigin(QGraphicsItem*, QGraphicsItem*)’:
demo.cpp:146: error: invalid conversion from ‘QPointF*’ to ‘int’
demo.cpp:146: error: initializing argument 1 of ‘QPolygonF::QPolygonF(int)’
demo.cpp:146: error: no match for ‘operator=’ in ‘relativePoint = QGraphicsItem::mapToItem(const QGraphicsItem*, const QPolygonF&) const(((const QGraphicsItem*)mySecondItem), ((const QPolygonF&)(& QPolygonF(((int)centrePoint)))))’
/usr/local/Trolltech/Qt-4.3.4/include/QtCore/qpoint.h:190: note: candidates are: QPointF& QPointF:perator=(const QPointF&)

Can anyone suggest where I am going wrong?