Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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