If you try to zoom in on our custom rectangles scene (for example, by calling view.scale(4, 4)) , you will note that everything is scaled proportionally, as you would expect. However, there are situations where you don't want some elements to be affected by scale or other transformations. Qt provides multiple ways to deal with it.
If you want lines to always have the same width, regardless of the zoom, you need to make the pen cosmetic:
QPen pen = parent->pen(); pen.setCosmetic(true); parent->setPen(pen);
Now, the rectangles will always have lines with one-pixel width, regardless of the view's scale (anti-aliasing can still blur them, though). It's also possible to have cosmetic pens with any width, but using them ...