Search code examples
c++qtqgraphicsitem

Draw border of QGraphicsItem


How to draw border of QGraphicsItem ? Simple painter->drawRect( boundingRect() ) in overloaded paint method is not correct(bottom-right corner is outside the item).


Solution

  • I found out my problem. Thanks for all advises, but now I see, that my problem was elsewhere.

    I can draw a QRectF(), which fits to boundingRect of my item, but... when I scale my QGraphicsView (no matter if I use fitInView() method, or my own implementation) there are some errors in displaying my border.

    Rarely one or two lines of rect are tighter then others. I think that it can be be related to my QGraphicsItems, which are also QGraphicsSvgItems at once.