Need to transform polygon vertexes on the fly till origin point 0,0 (instead of center).
I have polygon ( 8x64 ) (with predefined vertex):
QPolygonF cursor;
cursor << QPointF(-4, 32);
cursor << QPointF(-4, -32);
cursor << QPointF(4, -32);
cursor << QPointF(4, 32);
Then I draw it and use as cursor:
QPixmap pixmap( cursor.boundingRect().width()+1, cursor.boundingRect().height()+1 );
pixmap.fill( QColor( Qt::black) );
QPixmap alpha = pixmap.createMaskFromColor(QColor( Qt::black ),Qt::MaskOutColor);
pixmap.setAlphaChannel( alpha );
QPainter painter( &pixmap );
painter.setPen( QPen( Qt::green) );
// move to center, because polygon coordinated starts from center
painter.translate(cursor.boundingRect().width()/2, cursor.boundingRect().height()/2 );
painter.drawPolygon( cursor );
setCursor( pixmap );
But after mouse click, I have mouse position at center of this polygon, this is normal and logical.
Question, how to transform polygon on the fly ( transform matrix or such ) to 0,0 origin point and get after mouse click top, left coordinates (instead of center) ?