[Development] New high-dpi QPen proposal (Was Re: Proposal: Make QPen non-cosmetic by default)

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Thu Oct 18 11:08:30 CEST 2012


> Maybe as a best effort we could introduce a different render hint, 
> asking QPainter to treat cosmetic pens as geometric, would be a better 
> solution for Morten's high-dpi use case. Then it would be opt-in instead 
> of opt-out, and no existing applications would be affected. Turning on 
> high-dpi mode could be documented to also set the render hint.
...
> In summary (or TL;DR), my new proposal would be to just make 
> QPainter::NonCosmeticDefaultPen work as advertised, and have it be set 
> by default when high-dpi mode is enabled. This way there would be 
> minimal breakage of existing code. Thoughts?


No I don't think this would work. That way we will get the obscure scalability issues that Uwe mentioned but it would only happen on retina capable computers so it can become even harder to discover.

The original proposal doesn't really have these problems though. We already set the render hint NonCosmeticPenByDefault on GraphicsView to avoid inconsistent scalability issues there and keep style code working when being scaled. 

I think we should extend this behavior to QPainter in general by only initialising QPen to 1 instead of 0. We keeping the explicit 0-pen working as before. In addition, we introduce a CosmeticPenByDefault render hint  that Qwt can set on its painter to make all pens cosmetic by default. (not just 0-pen) Though the Qt4PainterRenderHint could still explicitly give only 0 pen cosmetic properties.

This should have a very minimal impact on existing code, while at the same time addressing the fact that most code written with the implicit QPen constructor in mind, does not expect a cosmetic pen. Or the pen to change by simply setting a different width on it.

Jens


More information about the Development mailing list