Qt6 topics merged with General

get new point coordinates on a rect after applying transformation

  • I rotated a rect to 90 on its center. P is point on initial rect,
    QPoint P(x,y);

    qreal angle = ...;
    QRect rect = ...;
    Qpoint center = rect.center();
    QTransform t = QTransform().translate( center.x(), center-y() ).rotate( angle ).translate( -center.x(), -center.y() );
    Qrect rotatedRect = t.mapToRect( rect );

    Now how to get new coordinated of P on rotatedRect ?

  • QPoint rotatedP = t.map(P);

Log in to reply