QGraphicsItem clip to scene Rect

  • Hi,
    I'm trying to clip my items inside the scene rect.
    I have customs items whith the paint method redifined and the following line inside it:


    where the rect is my scene rect. If no rotation is applied to the item or if the rotation is 90, 180 or 270 degrees it works well but when I rotate the item by 45° for example (using qtransform) the rect return by mapRectFromScene is not what I expect.

    I have some difficulties understanding transformations and matrix, any help would be appreciated!


  • I've solved it like this (in custom item paint method):

        QRectF r = QRectF(0,0,50000,50000).translated(-scenePos());
        QPainterPath p;
        p = transform().inverted().map(p);

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.