Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Adjusting constant sizes to DPI



  • Adjusting QML to the system's DPI settings is mostly automatic: Fonts and images grow implicitly, and if my design honors these implicit sizes, the output should be nice.

    There is just one missing link for me: In some cases, I want to have a hard-coded minimum size. For example, a button should grow as more text is displayed, but it should never shrink below a certain size.

    This can be done easily by taking the maximum of the (implicit) text size and the minimum size.

    However, the minimum size is given in pixels, so it would need to be multiplied by a factor depending on the DPI used in the design vs. the system DPI.

    Is there a QML way to do it? My best idea right now is to register some context property or similar with this scaling factor, and multiply every constant size with that.



  • hi
    @Asperamanca said in Adjusting constant sizes to DPI:

    My best idea right now is to register some context property or similar with this scaling factor, and multiply every constant size with that.

    I think that is the right thing to do.
    https://doc.qt.io/qt-5/scalability.html


Log in to reply