Skip to content

Instantly share code, notes, and snippets.

@Zren
Last active May 4, 2020 20:38
Show Gist options
  • Save Zren/621338b8cda7c550d7b43f8ea1ba71a7 to your computer and use it in GitHub Desktop.
Save Zren/621338b8cda7c550d7b43f8ea1ba71a7 to your computer and use it in GitHub Desktop.
import QtQuick 2.4
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import org.kde.kirigami 2.12 as Kirigami
import org.kde.plasma.core 2.0 as PlasmaCore
GridLayout {
id: testing
columns: 2
property variant fontMetrics: TextMetrics {
text: "M"
}
property real devicePixelRatio: Math.max(1, ((fontMetrics.font.pixelSize*0.75) / fontMetrics.font.pointSize))
property int gridUnit: fontMetrics.height
Label { text: "units.gridUnit" } Label { text: units.gridUnit }
Label { text: "Kirigami.Units.gridUnit" } Label { text: Kirigami.Units.gridUnit }
Label { text: "units.devicePixelRatio" } Label { text: units.devicePixelRatio }
Label { text: "Kirigami.Units.devicePixelRatio" } Label { text: Kirigami.Units.devicePixelRatio }
Label { text: "fontMetrics.font.pixelSize" } Label { text: fontMetrics.font.pixelSize }
Label { text: "fontMetrics.font.pixelSize*0.75" } Label { text: fontMetrics.font.pixelSize*0.75 }
Label { text: "fontMetrics.font.pointSize" } Label { text: fontMetrics.font.pointSize }
Label { text: "testing.gridUnit" } Label { text: testing.gridUnit }
Label { text: "testing.devicePixelRatio" } Label { text: testing.devicePixelRatio }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment