QTextLength 类

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
QVariant operator QVariant () const
bool operator!= (const QTextLength & other ) const
bool operator== (const QTextLength & other ) const

详细描述

When we specify a value for the length of an element in a text document, we often need to provide some other information so that the length is used in the way we expect. For example, when we specify a table width, the value can represent a fixed number of pixels, or it can be a percentage value. This information changes both the meaning of the value and the way it is used.

Generally, this class is used to specify table widths. These can be specified either as a fixed amount of pixels, as a percentage of the containing frame's width, or by a variable width that allows it to take up just the space it requires.

另请参阅 QTextTable .

成员类型文档编制

enum QTextLength:: Type

This enum describes the different types a length object can have.

常量 描述
QTextLength::VariableLength 0 The width of the object is variable
QTextLength::FixedLength 1 The width of the object is fixed
QTextLength::PercentageLength 2 The width of the object is in percentage of the maximum width

另请参阅 type ().

成员函数文档编制

QTextLength:: QTextLength ()

Constructs a new length object which represents a variable size.

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

Constructs a new length object of the given type and value .

qreal QTextLength:: rawValue () const

Returns the constraint value that is specific for the type of the length. If the length is QTextLength::PercentageLength then the raw value is in percent, in the range of 0 to 100. If the length is QTextLength::FixedLength then that fixed amount is returned. For variable lengths, zero is returned.

QTextLength::Type QTextLength:: type () const

Returns the type of this length object.

另请参阅 QTextLength::Type .

qreal QTextLength:: value ( qreal maximumLength ) const

Returns the effective length, constrained by the type of the length object and the specified maximumLength .

另请参阅 type ().

QVariant QTextLength:: operator QVariant () const

Returns the text length as a QVariant

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

返回 true if this text length is different from the other text length.

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

返回 true if this text length is the same as the other text length.