aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickapplication_p.h
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2016-02-02 14:53:01 +0100
committerMitch Curtis <mitch.curtis@theqtcompany.com>2016-02-23 13:57:08 +0000
commit2b03ab642329d2498eafa35ae7159991db5791e4 (patch)
treea32cf55e5f5ef02da0ff651deb44283d62ff24d5 /src/quick/util/qquickapplication_p.h
parent72447b6dbf98ace65ec46559337243970a668d26 (diff)
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: - "<h3>Large text</h3>" - 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 <liang.qi@theqtcompany.com>
Diffstat (limited to 'src/quick/util/qquickapplication_p.h')
-rw-r--r--src/quick/util/qquickapplication_p.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h
index 971c9a203a..091cb094ed 100644
--- a/src/quick/util/qquickapplication_p.h
+++ b/src/quick/util/qquickapplication_p.h
@@ -52,6 +52,7 @@
//
#include <QtCore/QObject>
+#include <QtGui/QFont>
#include <qqml.h>
#include <QtQml/private/qqmlglobal_p.h>
#include <private/qtquickglobal_p.h>
@@ -66,6 +67,7 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(bool supportsMultipleWindows READ supportsMultipleWindows CONSTANT)
Q_PROPERTY(Qt::ApplicationState state READ state NOTIFY stateChanged)
+ Q_PROPERTY(QFont font READ font CONSTANT)
public:
explicit QQuickApplication(QObject *parent = 0);
@@ -74,6 +76,7 @@ public:
Qt::LayoutDirection layoutDirection() const;
bool supportsMultipleWindows() const;
Qt::ApplicationState state() const;
+ QFont font() const;
Q_SIGNALS:
void activeChanged();