En esta página

QTextLength Class

La clase QTextLength encapsula los diferentes tipos de longitud que se utilizan en un QTextDocument. Más información...

Encabezado: #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 otra información para que la longitud se utilice de la forma esperada. Por ejemplo, al especificar el ancho de una tabla, el valor puede representar un número fijo de píxeles o bien un porcentaje. Esta información modifica tanto el significado del valor como la forma en que se utiliza.

Por lo general, esta clase se utiliza para especificar los anchos de las tablas. Estos pueden especificarse como una cantidad fija de píxeles, como un porcentaje del ancho del marco que los contiene o mediante un ancho variable que les permita ocupar solo el espacio que necesiten.

Véase también QTextTable.

Documentación sobre los tipos de miembros

enum QTextLength::Type

Esta enumeración describe los diferentes tipos que puede tener un objeto de longitud.

ConstanteValorDescripción
QTextLength::VariableLength0La anchura del objeto es variable
QTextLength::FixedLength1El ancho del objeto es fijo
QTextLength::PercentageLength2El ancho del objeto se expresa en porcentaje del ancho máximo

Véase también type().

Documentación de las funciones de miembro

QTextLength::QTextLength()

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

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

Crea un nuevo objeto de longitud a partir de los valores « type » y « value » indicados.

qreal QTextLength::rawValue() const

Devuelve el valor de restricción específico para el tipo de longitud. Si la longitud es « QTextLength::PercentageLength », el valor sin procesar se expresa en porcentaje, dentro del intervalo de 0 a 100. Si la longitud es « QTextLength::FixedLength », se devuelve ese valor fijo. En el caso de 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, limitada por el tipo del objeto de longitud y el valor especificado en ` maximumLength`.

Véase también type().

QTextLength::operator QVariant() const

Devuelve la longitud del texto como un QVariant

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

Devuelve « true » si la longitud de este texto es diferente de la longitud del texto « other ».

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

Devuelve « true » si la longitud de este texto es igual a la del texto « 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.