[Development] Qt 6 high-dpi support
Morten Sørvig
Morten.Sorvig at qt.io
Wed May 13 16:53:11 CEST 2020
>
> P.S. Consider a similar type of "technical debt" being settled by Qt: I'm thinking of the "DPI awareness" setting in 5.14, i.e. for a default widgets program, Qt nowadays tells WIndows that it's "DPI aware" and wants the truth about screen coordinates, even on those portable PCs with high DPIs that have Scale set to 125% or 150%. On the Qt forum I've seen lot of heat/complaints about QLabels being shoehorned in with the QLineEdits because the fonts are too big for those 125% or 150% screens, I'd answer: create a qt.conf file with the contents:
> [Platforms]
> WindowsArguments = dpiawareness=0
>
> and your legacy widgets program will go back to display fine, albeit a bit blurry and bloated.
> But! If you're asking (with that qt.conf file present) what the screen size is (e.g. QGuiApplication::screens(0)->geometry() etc.) Windows will lie to you and scale "backwards" so that a normal 2560x1440 screen is reported as "QRect(0,0,1707,960)". So using dpiawareness=0 is a bad long-term solution :-(
We are indeed planning to addreess high-DPI support for Qt 6. You can test the implementation on
Qt 5.14+ today by setting
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
This should make sure labels and line edits are correctly sized, also for 125% and 150%.
Interestingly, Qt will then “lie” about the about the screen size the same way that dpiawareness=0
does, although while rendering at the full resolution (so no blurriness).
Morten
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development
More information about the Development
mailing list