Text size changes accordingly to the computer settings



  • Good evening,

    I finished a Qt program that works perfectly on my computer ; however when I tested it on someone else's, I noticed that all the texts displayed were too big for the widgets that contain them...
    This is caused by the settings on this person's computer (running on Windows 10), which had been parameterized in order to display text at 150% of its normal size (because the screen is smaller and displays everything smaller than usual).

    Therefore, I've thought about two different solutions to my issue :

    • prevent the size of the texts from adapting accordingly to the computer settings (in which case it may be difficult to read on screens like the one I talked about)
    • adapt all the widgets to the size of the text they contain, without having two widgets overflow on each other

    Which solution would be the easier one? I have no idea how to proceed.
    Thank you,

    Telergoel


  • Moderators

    @Telergoel Do you use layouts in your Qt program? If so then the widgets should adjust their size so the content fits.



  • There are use cases where it's important that the output looks the same on all computers. In this case, you can use the pixelSize in fonts.
    However, for most cases, the better approach is to have an UI that adapts to the changing font size, e.g. using layouts.


  • Moderators

    @Telergoel
    about what kind of widgets are we talking here?
    I am asking because normally the font-size should be already considered in the widget's sizeHint.
    Also i am not awaye (yet) of an event notifier for such a system change.

    I guess it only applies for the dpi scaling during rendering the font/text?
    So probably the text rendering engine takes some system properties to do the rendering.

    Read this and give the dpi-awareness (set to "0" i guess) approach a try.
    Or try setting the Qt::AA_DisableHighDpiScalingapplication attribute.



  • Hello,
    sorry for answering late, I've been working on other things since then.

    I already use layouts. You have to understand that if I change the font size in Qt Creator, the widgets will adapt automatically ; they just won't if the text size is changed from the OS settings (I only tried on Windows, but I guess it would be the same on Linux or Mac).

    The widgets I'm talking about are labels, buttons, or even tabs of a QTabWidget (basically any widget that contains text is affected). The problem seems to happen on any computer if I change the text size in Windows settings.

    Here are screenshots showing the displayed window when setting the text size at 125% first, 100% then (on Windows 8): http://imgur.com/a/NHtHe

    Telergoel


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.