[Development] Proposal: Make QPen non-cosmetic by default
Jens.Bache-Wiig at digia.com
Fri Oct 12 12:10:59 CEST 2012
> Think about a scatter plot with many points displayed as crosses. On a
> large zoom level you only see a cloud but when zooming in you can see
> each cross and its position in detail.
True. There are certainly plenty of valid use cases out there and some of those would require a minor change in Qt5 if we go ahead with this change. Most likely no more than setRenderHint(Qt::CosmeticDefaultPen, true).
QPen right now is inconsistent and prone to errors. QPen() and QPen(Qt::red) Is not only defaulting to cosmetic, but also (arbitrarily and arguably incorrect on retina) a pen size of 1 pixel. QPen(Qt::black, 2), is non-cosmetic with a width of 2. In fact all non-0 values for pen width are non-cosmetic by default so making only the default constructor a special case with a cosmetic pen of size 1 is arbitrary and confusing regardless if you are using a cosmetic pen or not in your application.
Thinking more about it, I think even maintaining QPen(colour, 0) as a special case with the current behavior is wrong. If a user needs cosmetic pen for a graph, he/she should always use setCosmetic(true) on the pen and be explicit about it so that any pen size he defines is cosmetic. Chances are anyone creating a non-trivial chart or pdf application will already have to do this because you have to be able to deal with more than one line thickness anyway.
More information about the Development