From 2b03ab642329d2498eafa35ae7159991db5791e4 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 2 Feb 2016 14:53:01 +0100 Subject: Expose Qt.application.font This is useful in order to specify font sizes that are some multiple of the default size (which is almost always guaranteed to be a sensible, legible size). For example: Text { text: "Large text" font.pixelSize: Qt.application.font.pixelSize * 2 } Other options are: - "

Large text

" - adds extra space below the text since it's a HTML element, so not really useful if you want a decent layout. - Hard-coding a pixel size. Works OK when used in combination with Qt::AA_EnableHighDpiScaling, and so long as you guess the correct size that works for each device/display you're targeting. Doesn't work without setting Qt::AA_EnableHighDpiScaling. - Using FontMetrics/TextMetrics. Works fine, but is a bit verbose. - Use an empty Text element. Creates an unnecessary item. Was superseded by FontMetrics/TextMetrics. - defaultPixelSize/implicitPixelSize and defaultPointSize/implicitPointSize. There are already font-related properties outside of the font grouped property, so this wouldn't be out of place, but the API is already quite large. [ChangeLog][QtQuick] Added Qt.application.font property. Change-Id: I2d0899f2a6b717aab9afcea59f42fbf3715d8406 Task-number: QTBUG-50298 Reviewed-by: Liang Qi --- src/quick/util/qquickapplication.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/quick/util/qquickapplication.cpp') diff --git a/src/quick/util/qquickapplication.cpp b/src/quick/util/qquickapplication.cpp index a4e2f0eb0e..5c26b23ff7 100644 --- a/src/quick/util/qquickapplication.cpp +++ b/src/quick/util/qquickapplication.cpp @@ -90,4 +90,9 @@ Qt::ApplicationState QQuickApplication::state() const return QGuiApplication::applicationState(); } +QFont QQuickApplication::font() const +{ + return QGuiApplication::font(); +} + QT_END_NAMESPACE -- cgit v1.2.3