Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTextLength Class Reference

\reentrant More...

#include <qtextformat.h>

+ Collaboration diagram for QTextLength:

Public Types

enum  Type { VariableLength = 0 , FixedLength , PercentageLength }
 This enum describes the different types a length object can have. More...
 

Public Member Functions

 QTextLength ()
 Constructs a new length object which represents a variable size.
 
 QTextLength (Type type, qreal value)
 Constructs a new length object of the given type and value.
 
Type type () const
 Returns the type of this length object.
 
qreal value (qreal maximumLength) const
 Returns the effective length, constrained by the type of the length object and the specified maximumLength.
 
qreal rawValue () const
 Returns the constraint value that is specific for the type of the length.
 
bool operator== (const QTextLength &other) const
 Returns true if this text length is the same as the other text length.
 
bool operator!= (const QTextLength &other) const
 Returns true if this text length is different from the other text length.
 
 operator QVariant () const
 Returns the text length as a QVariant.
 

Friends

Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QTextLength &)
 
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QTextLength &)
 

Detailed Description

\reentrant

The QTextLength class encapsulates the different types of length used in a QTextDocument. \inmodule QtGui

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.

See also
QTextTable

Definition at line 44 of file qtextformat.h.

Member Enumeration Documentation

◆ Type

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

\value VariableLength The width of the object is variable \value FixedLength The width of the object is fixed \value PercentageLength The width of the object is in percentage of the maximum width

See also
type()
Enumerator
VariableLength 
FixedLength 
PercentageLength 

Definition at line 47 of file qtextformat.h.

Constructor & Destructor Documentation

◆ QTextLength() [1/2]

QTextLength::QTextLength ( )
inlineexplicit

Constructs a new length object which represents a variable size.

Definition at line 49 of file qtextformat.h.

◆ QTextLength() [2/2]

QTextLength::QTextLength ( Type type,
qreal value )
inlineexplicit

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

Definition at line 82 of file qtextformat.h.

Member Function Documentation

◆ operator QVariant()

QTextLength::operator QVariant ( ) const

Returns the text length as a QVariant.

Definition at line 109 of file qtextformat.cpp.

References QVariant::fromValue().

+ Here is the call graph for this function:

◆ operator!=()

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

Returns true if this text length is different from the other text length.

Definition at line 69 of file qtextformat.h.

References other(), and qFuzzyCompare().

+ Here is the call graph for this function:

◆ operator==()

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

Returns true if this text length is the same as the other text length.

Definition at line 66 of file qtextformat.h.

References other(), and qFuzzyCompare().

+ Here is the call graph for this function:

◆ rawValue()

qreal QTextLength::rawValue ( ) const
inline

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.

Definition at line 64 of file qtextformat.h.

◆ type()

Type QTextLength::type ( ) const
inline

Returns the type of this length object.

See also
QTextLength::Type

Definition at line 53 of file qtextformat.h.

Referenced by operator<<().

+ Here is the caller graph for this function:

◆ value()

qreal QTextLength::value ( qreal maximumLength) const
inline

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

See also
type()

Definition at line 54 of file qtextformat.h.

Referenced by QTextDocumentLayoutPrivate::drawBlock().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator<<

Q_GUI_EXPORT QDataStream & operator<< ( QDataStream & stream,
const QTextLength & length )
friend

Definition at line 115 of file qtextformat.cpp.

◆ operator>>

Q_GUI_EXPORT QDataStream & operator>> ( QDataStream & stream,
QTextLength & length )
friend

Definition at line 120 of file qtextformat.cpp.


The documentation for this class was generated from the following files: