How QML determines default font.pixelSize
Solved
QML and Qt Quick
-
wrote on 27 Jan 2021, 20:03 last edited by SeeLook
Hi.
I'm trying to figure out how QML determines
font.pixelSize
, because it is not simplyFontMetrics.height
(orqApp->fontMetrics().height()
)
I. e. for system font size set to 12:
qApp->font().pointSize()
is exactly 12 the same as QMLfont.pointSize
qApp->fontMetrics().height()
is 19 (the same as QML FontMetrics)
but
qApp->font().pixelSize()
is -1 mens undefined
whereas QMLfont.pixelSize
is 16
So how to obtain this last value, knowing system font size (pointSize) before QML will be initialized? -
wrote on 27 Jan 2021, 21:06 last edited by SeeLook
OK. I've got it....
auto pixelSize = qApp.font().pointSizeF() / 72.0 * qApp->primaryScreen()->logicalDotsPerInch();
1/2