QTextLength Class
QTextLength 类封装了QTextDocument 中使用的各种长度类型。更多内容...
| 头文件: | #include <QTextLength> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
| qmake: | QT += gui |
- 所有成员的列表,包括继承的成员
- QTextLength 是富文本处理 API 的一部分。
注意:该类中的所有函数均为可重入的。
公共类型
| 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::VariableLength | 0 | 对象的宽度是可变的 |
QTextLength::FixedLength | 1 | 对象的宽度是固定的 |
QTextLength::PercentageLength | 2 | 对象的宽度以最大宽度的百分比表示 |
另请参阅 type()。
成员函数文档
QTextLength::QTextLength()
创建一个新的长度对象,该对象表示一个可变大小。
[explicit] QTextLength::QTextLength(QTextLength::Type type, qreal value)
根据给定的type 和value ,创建一个新的长度对象。
qreal QTextLength::rawValue() const
返回针对长度类型特有的约束值。如果长度为QTextLength::PercentageLength ,则原始值以百分比为单位,范围为0到100。如果长度为QTextLength::FixedLength ,则返回该固定数值。对于可变长度,返回零。
QTextLength::Type QTextLength::type() const
返回此长度对象的类型。
另请参阅 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.