HiDPI monitors

Maurizio Berti maurizio.berti at gmail.com
Wed Jan 13 13:57:33 GMT 2021


I've seen this kind of behavior on hidpi screens, and, besides correctly
setting the DPI "awareness", they usually depend on inconsistencies in
creating the ui, especially when mixing together Designer created uis,
custom widgets, dynamically created widgets and "scattered" stylesheets.

I have some general suggestions, based on my experience:

- when creating UIs with Designer be always very careful when setting
properties (especially those that have impact on sizes, including fonts):
if a property value is the same as the default, always reset it as implicit
unless absolutely required;
- when creating custom widgets that internally compute sizes or geometries,
consider always checking (and caching) the device DPI, especially if the
size hint or a minimum/maximum size has to be set;
- if a custom font has to be used, try to get the default font from the
application and use its size; if a global custom font is going to be set,
store the default one when the application is created as a reference;
- it's usually better to have a *centralized* stylesheet (for the top level
window or even the application), as it makes it easier to track down issues
or change global properties; it can make things a bit harder, as selectors
must be carefully created, but it's generally worth it;
- avoid hardcoded font sizes for QFont with setPointSize or setPointSizeF
(depending on the system and its settings, it might not work as expected);
if you need a font size bigger or smaller than the default one, always use
the default (widget or application) font size as a reference;
- do not use px units in stylesheets; prefer pt for graphics or em/ex for
lengths that must consider font sizes; alternatively, compute the sizes on
runtime (another reason for using a centralized stylesheet);

Maurizio

Il giorno mer 13 gen 2021 alle ore 12:04 ullix <ullix at urkam.de> ha scritto:

> I forgot to mention the user is using Windows 10
>
>
> Am 13.01.21 um 11:38 schrieb VA:
> > Le 13/01/2021 à 10:51, ullix a écrit :
> >> I can't test a HiDPI screen at the moment. What benefit would/might
> >> it have in this situation? Anything else to do?
> >>
> >
> > I don't have a HiDPI monitor but I use Xephyr and this to simulate
> > higher-resolutions, and possibly tweaking DPI:
> > https://indigo.re/posts/2020-05-18-hidpi-testing.html
> >
> > It seems sometimes the issue is a misconfiguration of the X server.
> > For example, see https://github.com/hydrargyrum/lierre/issues/4
> > (especially the last messages)
> >
> > Hope it helps.
>
>

-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210113/6d54b92e/attachment.htm>


More information about the PyQt mailing list