Please nominate your Qt Champions for 2021!

Windows scaling impact in Qt application and mainly on QFontMetrics

  • Hello,

    I have several problems on my Qt application (developped with Qt 5.14.2) linked to Windows scaling.
    For example, I'm at 125% on my conputer and lines in table are too high, tabs in QTabWidget are also too high, but the main problem for me is that QFontMetrics.horizontalAdvance is really too wide (I use it to draw a selection rectangle around the text which is too wide).
    When I switch to 100%, everything is ok.

    I've looked at this page and, just before QApplication is created, I've added :


    But nothing changes.
    I've also tried to set environment variables as shown in the High DPI page but nothing changes.

    Do you have an idea on how I can correctly take into account Windows scaling to avoir these behaviours, mainly for QFontMetrics ?
    Do you think it's a Qt bug ?

    Thank you for your help.


Log in to reply