TextMetrics QML Type
与えられたフォントとテキストに対するメトリクスを提供します。詳細...
| Import Statement: | import QtQuick |
プロパティ
- advanceWidth : real
- boundingRect : rect
- elide : enumeration
- elideWidth : real
- elidedText : string
- font : font
- height : real
- renderType : enumeration
(since 6.3) - text : string
- tightBoundingRect : rect
- width : real
詳細説明
TextMetrics は、与えられたテキスト文字列の様々なプロパティを特定のフォントについて計算します。
引数をとるQFontMetricsF の関数に対する宣言的 API を提供します。
TextMetrics {
id: textMetrics
font.family: "Arial"
elide: Text.ElideMiddle
elideWidth: 100
text: "Hello World"
}
MyItem {
text: textMetrics.elidedText
}QFontMetricsF およびFontMetricsも参照して ください。
プロパティのドキュメント
advanceWidth : real [read-only]
このプロパティは、text の文字の進み具合をピクセル単位で保持する。これは、文字列の位置から次の文字列が描画されるべき位置までの距離である。
QFontMetricsF::horizontalAdvance()も参照 。
boundingRect : rect [read-only]
このプロパティは、text で指定された文字列の文字の外接矩形を保持する。
QFontMetricsF::boundingRect() およびtightBoundingRectも参照のこと 。
elide : enumeration
このプロパティは、テキストのエライド・モードを保持する。これは、文字列がエライドされる位置を決定する。可能な値は
| 定数 | 説明 |
|---|---|
Qt::ElideNone | これはデフォルト値です。 |
Qt::ElideLeft | これはデフォルト値です:"...世界" |
Qt::ElideMiddle | 例えば"He...ld" |
Qt::ElideRight | 例えば「こんにちは |
elideWidth およびQFontMetrics::elidedTextも参照の こと。
elideWidth : real
こ のプ ロパテ ィ は、 テ キ ス ト がエ リ ーデ ィ ン グ さ れ る 前に持つ こ と がで き る 最大の幅を (ピ ク セル単位で) 保持 し ます。
elide とQFontMetrics::elidedTextも参照してください 。
elidedText : string [read-only]
このプロパティは、文字列text の幅がelideWidth よりも広い場合、その文字列のエリッドバージョン(つまり、"..." が含まれる文字列)を保持する。 文字列の幅がelideWidth よりも広くない場合、またはelide がQt::ElideNone に設定されている場合、このプロパティは元の文字列と等しくなる。
QFontMetricsF::elidedText()も参照のこと 。
font : font
このプロパティは、メトリクス計算に使用されるフォントを保持します。
height : real [read-only]
このプロパティは、text で指定された文字列の文字の外接矩形の高さを保持する。と等価である:
textMetrics.boundingRect.height
boundingRectも参照してください 。
renderType : enumeration [since 6.3]
このコンポーネントのデフォルトのレンダリングタイプをオーバーライドします。
サポートされるレンダリングタイプは以下の通りです:
| 定数 | 説明 |
|---|---|
TextEdit.QtRendering | テキストは、各グリフに対してスケーラブルな距離フィールドを使用してレンダリングされる。 |
TextEdit.NativeRendering | テキストは、プラットフォーム固有の技法を使用してレンダリングされます。 |
これは、テキストを描画するrenderType の意図と一致する必要があります。
このプロパティは Qt 6.3 で導入されました。
Text.renderTypeも参照してください 。
text : string
このプロパティは、メトリクスの計算に使用されるテキストを保持します。
tightBoundingRect : rect [read-only]
このプロパティは、text で指定された文字列の文字を囲むタイトな外接矩形を保持します。
QFontMetricsF::tightBoundingRect() およびboundingRectも参照のこと 。
width : real [read-only]
このプロパティは、text で指定された文字列の文字の外接矩形の幅を保持する。と等価である:
textMetrics.boundingRect.width
boundingRectも参照してください 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.