Summary: | New check: warn on hidpi issues | ||
---|---|---|---|
Product: | [Developer tools] clazy | Reporter: | Nyall Dawson <nyall.dawson> |
Component: | general | Assignee: | Unassigned bugs mailing-list <unassigned-bugs> |
Status: | RESOLVED LATER | ||
Severity: | wishlist | CC: | smartins |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Nyall Dawson
2019-01-13 23:05:13 UTC
It's completely ok to use setFixedSize(16, 16), as those 16x16 pixels are not really physical pixels, but logical pixels. Qt converts from logical to physical internally, depending on your hdpi settings, and there's no need for the user to do the scaling on his own. Sergio - is that also the case for methods like setIconSize? My experience has been the opposite, under both Windows 10 and Fedora (Gnome Shell), on a Dell XPS 13. ANY fixed sizes are hugely undersized on the display. And indeed, the Qt docs state the same: "Replace hard-coded sizes in layouts and drawing code by values calculated from font metrics or screen size." (http://doc.qt.io/qt-5/highdpi.html) For icon sizes you need AA_UseHighDpiPixmaps and AA_EnableHighDpiScaling
>> "Replace hard-coded sizes in layouts and drawing code by values calculated from font metrics or screen size."
I don't think this is correct, and instead people are just using AA_EnableHighDpiScaling, even in new projects, not only legacy ones.
Suppose you're using a QComboBox, how do you replace the hardcoded sizes/margins from its implementation which you don't have access to ? Providing your own QStyle is a lot of work.
Furthermore, there's a bunch of new HDPI work in Qt's codereview, which might change some of these recommendations, and also support floating-point factors.
I don't think we're ready for a clazy check at this time, since even the Qt maintainers send mixed signals about what to use.
See also the mailing lists, there's lots of doubts about all this
I'll move this suggestion to the "Later" queue, and re-open if anything changes upstream, thanks!
|