diff options
| author | Mitch Curtis <[email protected]> | 2014-08-05 17:42:54 +0200 |
|---|---|---|
| committer | Mitch Curtis <[email protected]> | 2014-08-08 10:42:47 +0200 |
| commit | 94669499fd943fc72095afd739a21cd8e675f14f (patch) | |
| tree | d902820ebbc41f75699326fa1cf887ee49fc6746 /src/quick/util/qquickutilmodule.cpp | |
| parent | c0e47716c402da2333bfa4082c7b40e3b376135c (diff) | |
Add declarative QQuickTextMetrics API from QQuickFontMetrics invokables
This allows use of a declarative API for the functions in QFontMetricsF
which take parameters. This solves the problem of QML expressions that
use QML methods not being re-evaluated when the internal data changes,
by allowing the user to set the arguments as properties of a
TextMetrics object, that would otherwise have to be passed to QML
methods.
For example:
FontMetrics {
id: fontMetrics
}
property rect r: fontMetrics.boundingRect("Blah")
At some point, the font of the FontMetrics object is changed, but r
will still represent the original bounding rect. Instead, the user will
now write:
TextMetrics {
id: textMetrics
text: "Blah"
}
property rect r: textMetrics.boundingRect
The QML methods remain in QQuickFontMetrics for those who need an
imperative API.
[ChangeLog][QtQuick] Added QQuickTextMetrics, which provides a
declarative API for the functions in QFontMetricsF which take
arguments.
Change-Id: I019dc4639531906fc751ba61281cc1c695742287
Reviewed-by: J-P Nurmi <[email protected]>
Diffstat (limited to 'src/quick/util/qquickutilmodule.cpp')
| -rw-r--r-- | src/quick/util/qquickutilmodule.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp index 1d82cfca43..8ea903b010 100644 --- a/src/quick/util/qquickutilmodule.cpp +++ b/src/quick/util/qquickutilmodule.cpp @@ -53,6 +53,7 @@ #include "qquickstate_p.h" #include "qquickstate_p_p.h" #include "qquicksystempalette_p.h" +#include "qquicktextmetrics_p.h" #include "qquicktransition_p.h" #include "qquickanimator_p.h" #include <qqmlinfo.h> @@ -109,4 +110,5 @@ void QQuickUtilModule::defineModule() qmlRegisterUncreatableType<QKeySequence, 2>("QtQuick", 2, 2, "StandardKey", QStringLiteral("Cannot create an instance of StandardKey.")); qmlRegisterType<QQuickFontMetrics>("QtQuick", 2, 4, "FontMetrics"); + qmlRegisterType<QQuickTextMetrics>("QtQuick", 2, 4, "TextMetrics"); } |
