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

Setting QSS font-size and varying DPIs



  • Hi,

    I'm wondering how I should be setting the font-size in QSS so that it works well for monitors of any DPI on Windows.

    Currently, I have styles that looks like this:

    QLabel {
        font-size: 12px;
    }
    

    Because the unit is in pixels, it looks small on high DPI monitors.
    Specifying the units using pt makes them look thicker than they should.

    Is there something I'm missing that might be needed?

    Thank you



  • I think pt is the right way.
    I feel 9pt looks the same as 12px in normal DPI.



  • @Bonnie
    I've often struggled with this (in HTML/CSS rather than Qt). Is "always specify your font size in pt rather than px" a general/successful rule? But then if text has to fit into somewhere like, say, a box specified in pixels, you have headaches again, correct?



  • @Bonnie said in Setting QSS font-size and varying DPIs:

    the right way.
    I feel 9pt looks the same

    It does appear to be the right size but then text looks fuzzy when I switch to using it. I'm not sure how to explain it.



  • @J-Andre
    I would imagine specifying in pt has to scale on a monitor hence the fuzziness, where px would fit exactly?


Log in to reply