Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

How to automatically resize all widgets when Display DPI scale is changed



  • On Windows, in the display settings I could change the size of the contents of the screen in %.
    Now, if the display settings were updated BEFORE launching the GUI, the GUI would look fine.
    However, if the display settings were updated WHILE the GUI is open, then all fonts would increase (as expected) in size but the widgets such as push buttons and others would stay the same size (unlike in the previous scenario).

    So after some research and thinking, it might make sense to use:

    1. QScreen::logicalDotsPerInchChanged signal to signal that display settings were changed.
    2. Upon receiving this signal, the whole ui window should update all of its widgets to match this new scale % factor.

    Btw, this question was asked and solved before; however, without showing some implementation as in : here

    So my question resides in how can this be implemented:

    • For number 1: where do I place this signal connection and how can I react to it
    • For number 2: what is a good way to resize or update widgets without doing so one by one, but rather at the ui window level.

  • Lifetime Qt Champion

    Hi,

    In fact, there was no solution and the original poster did not provide a link to the relevant mailing list thread.

    Which version of Qt are you using ?



  • @SGaist Hi, I'm using v5.13.1 on Windows with msvc build.


  • Lifetime Qt Champion

    Then you should try a more recent version. IIRC there has been some work on that field.


Log in to reply