Important: Please read the Qt Code of Conduct -

[SOLVED] problems with fonts and scaling

  • [SOLUTION: Set Windows font-size to 100%]

    I am using Qt5.3.1 on Windows 8.1 only

    I have two laptops- the development PC and another one I'm testing my deploy on.

    Both laptops at 1920x1080 and under the "make text and other items larger or smaller" I have both set at the smallest setting.

    On my development PC where I've laid out my windows etc, everything looks proper.

    But on the deploy PC (which has same settings and same installed fonts) some of my windows are all crowded, with buttons, tabs, drop-down contents all crowded or overflowing.

    I tried adding this to main.cpp:
    QFont newFont("Seqoe UI", 10, QFont:::Normal, false);

    Then, again, everything looks fine on DEV, with the new font displayed everywhere.. But again, on the deploy PC, I see the Segoe UI font is used, but again things are all crowded and overflowing.

    Most of the controls that are having problems are inside layouts.

    Any ideas how I can ensure a consistent look across Windows PCs or suggestions as to what I may have done wrong?

    (ps. I've tried to put blank lines in my post here to make paragraphs for readability, but for some reason they seem to be stripped when I preview/submit)

  • Moderators

    Are we talking about a QtQuick application, or a QtWidgets-based one?

    I suspect your layout definitions are wrong, you might have put size constrains on the widgets and that forces the layout to look as it does. What happens when you resize the window on your dev machine? Do you get any strange-looking layouts?

    And if it is about QtQuick: you can be more certain about things when you use PixelSize in fonts instead of PointSize.

  • QtWidgets

    The thing is, the window I made is a fixed size - it's a control panel for external hardware, not like a document editing app where somebody could open it to any size.

    I used layouts within the window where I could, some are custom layouts. Everything looks just fine on the dev PC.

  • edit: the particular layout of the controls seems to maintain consistency.. it is literally that the fonts are much larger on the deployment PC but I can't make sense of why.

  • Moderators

    Here is the thing, then: it's best to design and implement the UI as if it was intended to be resized. Once everything works fine and can be set to any size, you just call setFixedSize() on the top-level widget (or set it's minimumSize and maximumSize to the same value). If you do that, you can be almost certain that it will look good on any other machine.

    Your use-case looks a bit special (from your description), so I am not sure my hint applies there.

  • I made a very simple single window app that does nothing but display some drop-down boxes and can be resized.. the font is still a different size on the deploy PC than it is on my development PC.

  • You are sure that the DPI settings are the same?
    Try using setPixelSize on the font (just for testing, it shouldn't really be used for scalable UIs)

  • ahh yes.. it turns out in Win8.1 there is a difference between the "change the size of all items" and what you can do if you check "Let me choose one scaling level" - with that activated I saw that the "deploy laptop" was at 150% whereas Dev laptop was at 100%

    When changed, they look consistent.

    But of course that brings another thing for me to consider - handling when a user does choose something other than 100% for this setting.

Log in to reply