Why is there no QTransform::fromRotate?

Viewed 170

Qt's QTransform offers some more optimized ways to construct a translated/scaled QTransform matrix using these static methods:

Now I need a rotatated transform and I thought it would be nice to also have a QTransform::fromRotate. But this one does not exist.

In my case I am modifying a existing transform accordingly to mouse interaction like paning, zooming and also rotating.

void MapDrawingItem::wheelEvent(QWheelEvent* event)
{
    //Moving the hovered point to the top left point on screen
    m_view_transform *= QTransform::fromTranslate(-event->posF().x(), -event->posF().y());

    //Apply transformations accordingly
    if((event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier)
        m_view_transform *= QTransform().rotate(event->delta() / 30.);
    else
    {
        auto factor = qPow(1.001, event->delta());
        m_view_transform *= QTransform::fromScale(factor, factor);
    }

    //Move the hovered point back to the mouse cursor
    m_view_transform *= QTransform::fromTranslate(event->posF().x(), event->posF().y());

    emit signalViewTransformChanged(m_view_transform);
    update();
}

The code works correctly, but I would like to replace the QTransform().rotate(...) with a QTransform::fromRotate(...)

Why does this method not exist already? I just can't imagine the Qt developers forgot for this one. Is there anything that makes this impossible?

1 Answers
Related