[Development] High-dpi Qt best practices

Pritam pritam_ghanghas at infosys.com
Tue Oct 9 11:59:56 CEST 2012


On Tuesday 09 October 2012 03:01 PM, Sorvig Morten wrote:
> On Oct 9, 2012, at 10:59 AM, Pritam <pritam_ghanghas at infosys.com>
>   wrote:
>> Forgive my ignorance, but I didn't understand. AFAIK most of Qt API is
>> in pixels. Do you mean after this patch, one should treat all API as points?
> No problem, the concepts are new and I'm still figuring out how they apply to Qt and how to best present them.
>
> If you don't care about supporting high-dpi you can continue as before, behaviour changes are opt-in. You can even get some support for free, for example text and mac style. If you work on Qt itself then I argue that you _should_ care about high-dpi.
>
> If you do want to support high-dpi then you should aware of the points/pixels distinction. And again the main message here is that very little changes, you deal with widget and event geometry as before and can draw using QPainter using the widget coordinate system. Behind the scenes QPainter will fill in 4x as many pixels on high-dpi displays. Which means you should provide more pixels when using raster images and pixmaps.
thanks for the explanation,  I am aware of distinction between point and 
pixels. But I was not aware that on mac all most of Qt API is point 
based as Eike pointed out. I dont develop for mac. But I like the idea.

We had to support different resolutions recently. We have most of our 
geometries supplied from stylesheet. I was thinking on similar lines. I 
was thinking that it will be great if Qt's stylesheet code determines a 
scale factor to be applied if dpi changes and pixmaps get picked up from 
the next higher resolution directory so that its always a scale down if 
at all scaling is required. In my case it will not be required because I 
have to support only a few already known screen sizes, I will provide 
raster images for those sizes. But I am not at liberty to change Qt, so 
I am doing all this from outside by changing pixmap directory and 
reapplying stylesheet with scaled factor applied to various sizes. Pixel 
based dimension suck when scalable UI has to be designed. I would love a 
seamlessly scalable generic solution within Qt.
> So it's mostly a name change. On high-dpi displays the main coordinate system units are not pixels any more, but we can pretend they are and get away with it in most cases.
>
> Morten
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
>


-- 
Regards,
Pritam


**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***



More information about the Development mailing list