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

How QML determines default font.pixelSize



  • Hi.

    I'm trying to figure out how QML determines font.pixelSize, because it is not simply FontMetrics.height (or qApp->fontMetrics().height())
    I. e. for system font size set to 12:
    qApp->font().pointSize() is exactly 12 the same as QML font.pointSize
    qApp->fontMetrics().height() is 19 (the same as QML FontMetrics)
    but
    qApp->font().pixelSize() is -1 mens undefined
    whereas QML font.pixelSize is 16
    So how to obtain this last value, knowing system font size (pointSize) before QML will be initialized?



  • OK. I've got it....

    auto pixelSize = qApp.font().pointSizeF() / 72.0 * qApp->primaryScreen()->logicalDotsPerInch();
    

Log in to reply