Alexander Dyagilev
Alexander Dyagilev

Reputation: 1425

QML get default font height value in pixels

Is there a way to get one?

Why I need it. Here I have bad looking UI: Quick Controls 2 bad looking

Here is how I can adjust checkbox size: QML: Resize CheckBox

I want indicator.height value to be equal to font's height.

Upvotes: 4

Views: 1441

Answers (1)

eyllanesc
eyllanesc

Reputation: 243897

To calculate the height of the font you must use FontMetrics:

CheckBox {
    text: "CheckBox"
    anchors.centerIn: parent
    checked: true

    indicator.width: indicator.height
    indicator.height: fontMetrics.height

    FontMetrics {
        id: fontMetrics
    }
}

enter image description here

Upvotes: 5

Related Questions