En esta página

QTextLength Class

La clase QTextLength encapsula los diferentes tipos de longitud utilizados en un QTextDocument. Más...

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

Nota: Todas las funciones de esta clase son reentrantes.

Tipos Públicos

enum Type { VariableLength, FixedLength, PercentageLength }

Funciones Públicas

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

Descripción Detallada

Cuando especificamos un valor para la longitud de un elemento en un documento de texto, a menudo necesitamos proporcionar alguna otra información para que la longitud se utilice de la forma que esperamos. Por ejemplo, cuando especificamos el ancho de una tabla, el valor puede representar un número fijo de píxeles, o puede ser un valor porcentual. Esta información cambia tanto el significado del valor como la forma en que se utiliza.

Generalmente, esta clase se utiliza para especificar anchos de tabla. Estas pueden especificarse como una cantidad fija de píxeles, como un porcentaje de la anchura del marco que la contiene, o mediante una anchura variable que le permite ocupar justo el espacio que necesita.

Véase también QTextTable.

Documentación de tipos de miembros

enum QTextLength::Type

Este enum describe los diferentes tipos que puede tener un objeto de longitud.

ConstanteValorDescripción
QTextLength::VariableLength0La anchura del objeto es variable
QTextLength::FixedLength1La anchura del objeto es fija
QTextLength::PercentageLength2La anchura del objeto está en porcentaje de la anchura máxima

Véase también type().

Documentación de las funciones miembro

QTextLength::QTextLength()

Construye un nuevo objeto de longitud que representa un tamaño variable.

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

Construye un nuevo objeto de longitud con los valores type y value.

qreal QTextLength::rawValue() const

Devuelve el valor de restricción específico para el tipo de longitud. Si la longitud es QTextLength::PercentageLength entonces el valor bruto está en porcentaje, en el rango de 0 a 100. Si la longitud es QTextLength::FixedLength entonces se devuelve esa cantidad fija. Para longitudes variables, se devuelve cero.

QTextLength::Type QTextLength::type() const

Devuelve el tipo de este objeto de longitud.

Véase también QTextLength::Type.

qreal QTextLength::value(qreal maximumLength) const

Devuelve la longitud efectiva, restringida por el tipo del objeto de longitud y el maximumLength especificado.

Véase también type().

QTextLength::operator QVariant() const

Devuelve la longitud del texto como QVariant

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

Devuelve true si esta longitud de texto es diferente de la longitud de texto de other.

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

Devuelve true si la longitud de este texto es la misma que la de other.

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