このページでは

QTextLength Class

QTextLength クラスは、QTextDocument で使用されるさまざまな種類の長さをカプセル化しています。詳細...

ヘッダー: #include <QTextLength>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

注:このクラスのすべての関数は再入可能です。

パブリック型

enum Type { VariableLength, FixedLength, PercentageLength }

パブリック関数

QTextLength()
QTextLength(QTextLength::Type type, qreal value)
qreal rawValue() const
QTextLength::Type type() const
qreal value(qreal maximumLength) const
operator QVariant() const
bool operator!=(const QTextLength &other) const
bool operator==(const QTextLength &other) const

詳細な説明

テキスト ドキュメント内の要素の長さの値を指定する場合、その長さが期待どおりに使用されるように、他の情報を指定する必要があることがよくあります。 たとえば、表の幅を指定する場合、その値は固定のピクセル数でも、パーセンテージ値でもかまいません。この情報によって、値の意味と使用方法が異なります。

一般的に、このクラスは表の幅を指定するために使用されます。幅は、固定のピクセル数、親フレームの幅に対するパーセンテージ、あるいは必要なスペースだけを占める可変幅のいずれかで指定できます。

QTextTableも参照してください 。

メンバ型のドキュメント

enum QTextLength::Type

この列挙型は、長さオブジェクトが持つことができるさまざまな型を表します。

定数値説明
QTextLength::VariableLength0オブジェクトの幅は可変です
QTextLength::FixedLength1オブジェクトの幅は固定です
QTextLength::PercentageLength2オブジェクトの幅は最大幅に対するパーセンテージで指定される

関連項目: type()。

メンバ関数のドキュメント

QTextLength::QTextLength()

可変長を表す新しい長さオブジェクトを作成します。

[explicit] QTextLength::QTextLength(QTextLength::Type type, qreal value)

指定されたtype およびvalue に基づいて、新しい長さオブジェクトを作成します。

qreal QTextLength::rawValue() const

長さの型に応じた制約値を返します。長さが `QTextLength::PercentageLength ` の場合、生データは 0 から 100 の範囲のパーセント値となります。長さが `QTextLength::FixedLength ` の場合、その固定値が返されます。可変長の場合は、0 が返されます。

QTextLength::Type QTextLength::type() const

このlengthオブジェクトの型を返します。

QTextLength::Typeも参照してください 。

qreal QTextLength::value(qreal maximumLength) const

長さオブジェクトの型および指定されたmaximumLength によって制約された、実効長を返します。

type()も参照してください 。

QTextLength::operator QVariant() const

テキストの長さをQVariant

bool QTextLength::operator!=(const QTextLength &other) const

このテキストの長さが、other のテキストの長さと異なる場合、true を返します。

bool QTextLength::operator==(const QTextLength &other) const

このテキストの長さが、other のテキストの長さと一致する場合、true を返します。

© 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.