Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

QTextFormat Class Reference

The QTextFormat class provides formatting information for a QTextDocument. More...

#include <QTextFormat>

Inherited by QTextCharFormat, QTextBlockFormat, QTextListFormat, and QTextFrameFormat.

Public Types

Public Functions


Detailed Description

The QTextFormat class provides formatting information for a QTextDocument.

A QTextFormat is a generic class used for describing the format of parts of a QTextDocument. The derived classes QTextCharFormat, QTextBlockFormat, QTextListFormat, and QTextTableFormat are usually more useful, and describe the formatting that is applied to specific parts of the document.

A format has a FormatType which specifies the kinds of thing it can format; e.g. a block of text, a list, a table, etc. A format also has various properties (some specific to particular format types), as described by the Property enum. Every property has a PropertyType.

The format type is given by type(), and the format can be tested with isCharFormat(), isBlockFormat(), isListFormat(), isTableFormat(), isFrameFormat(), and isImageFormat(). If the type is determined, it can be retrieved with toCharFormat(), toBlockFormat(), toListFormat(), toTableFormat(), toFrameFormat(), and toImageFormat().

A format's properties can be set with the setProperty() functions, and retrieved with boolProperty(), intProperty(), floatProperty(), and stringProperty() as appropriate. All the property IDs used in the format can be retrieved with allPropertyIds(). One format can be merged into another using merge().

A format's object index can be set with setObjectIndex(), and retrieved with objectIndex(). These methods can be used to associate the format with a QTextObject. It is used to represent lists, frames, and tables inside the document.

See also l{text.html}{Text Related Classes}.


Member Type Documentation

enum QTextFormat::FormatType

QTextFormat::InvalidFormat 
QTextFormat::BlockFormat 
QTextFormat::CharFormat 
QTextFormat::ListFormat 
QTextFormat::TableFormat 
QTextFormat::FrameFormat 
QTextFormat::UserFormat 

enum QTextFormat::ObjectTypes

QTextFormat::NoObject 
QTextFormat::ImageObject 
QTextFormat::TableObject 

enum QTextFormat::Property

QTextFormat::ObjectIndex 

Paragraph and character properties

QTextFormat::CssFloat 

Paragraph properties

QTextFormat::BlockDirection 
QTextFormat::BlockAlignment 
QTextFormat::BlockTopMargin 
QTextFormat::BlockBottomMargin 
QTextFormat::BlockLeftMargin 
QTextFormat::BlockRightMargin 
QTextFormat::BlockFirstLineMargin 
QTextFormat::BlockIndent 
QTextFormat::BlockNonBreakableLines 
QTextFormat::BlockBackgroundColor 

Character properties

QTextFormat::FontFamily 
QTextFormat::FontPointSize 
QTextFormat::FontSizeIncrement 
QTextFormat::FontWeight 
QTextFormat::FontItalic 
QTextFormat::FontUnderline 
QTextFormat::FontOverline 
QTextFormat::FontStrikeOut 
QTextFormat::FontFixedPitch 
QTextFormat::TextColor 
QTextFormat::IsAnchor 
QTextFormat::AnchorHref 
QTextFormat::AnchorName 
QTextFormat::ObjectType 

List properties

QTextFormat::ListStyle 
QTextFormat::ListIndent 

Table and frame properties

QTextFormat::TableColumns 
QTextFormat::FrameBorder 
QTextFormat::FrameMargin 
QTextFormat::FramePadding 
QTextFormat::Width 
QTextFormat::Height 
QTextFormat::TableColumnWidthConstraints 
QTextFormat::TableCellSpacing 
QTextFormat::TableCellPadding 
QTextFormat::TableBackgroundColor 

Table cell properties

QTextFormat::TableCellRowSpan 
QTextFormat::TableCellColumnSpan 
QTextFormat::TableCellBackgroundColor 

Image properties

QTextFormat::ImageName 
QTextFormat::ImageWidth 
QTextFormat::ImageHeight 
QTextFormat::UserProperty 

Member Function Documentation

QTextFormat::QTextFormat ()

Creates a new text format with an InvalidFormat.

See also FormatType.

QTextFormat::QTextFormat ( int type )

Creates a new text format of the given type.

See also FormatType.

QTextFormat::QTextFormat ( const QTextFormat & other )

Creates a new text format with the same attributes at the other text format.

QTextFormat::~QTextFormat ()

Destroys this text format.

bool QTextFormat::boolProperty ( int propertyId ) const

Returns the value of the property specified by propertyId. If the property isn't of QTextFormat::Bool type, false is returned instead.

See also setProperty(), intProperty(), floatProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), and PropertyType.

void QTextFormat::clearProperty ( int propertyId )

Clears the value of the property given by propertyId

QColor QTextFormat::colorProperty ( int propertyId ) const

Returns the value of the property given by propertyId; if the property isn't of QTextFormat::Color type, an invalid color is returned instead.

See also setProperty(), boolProperty(), intProperty(), floatProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), and PropertyType.

float QTextFormat::floatProperty ( int propertyId ) const

Returns the value of the property specified by propertyId. If the property isn't of QTextFormat::Float type, 0 is returned instead.

See also setProperty(), boolProperty(), intProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), and PropertyType.

bool QTextFormat::hasProperty ( int propertyId ) const

Returns true if the text format has a property with the given propertyId; otherwise returns false.

See also propertyType(), allPropertyIds(), and PropertyType.

int QTextFormat::intProperty ( int propertyId ) const

Returns the value of the property specified by propertyId. If the property is not of QTextFormat::Integer type, 0 is returned instead.

See also setProperty(), boolProperty(), floatProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), and PropertyType.

bool QTextFormat::isBlockFormat () const

Returns true if this text format is a BlockFormat; otherwise returns false.

bool QTextFormat::isCharFormat () const

Returns true if this text format is a CharFormat; otherwise returns false.

bool QTextFormat::isFrameFormat () const

Returns true if this text format is a FrameFormat; otherwise returns false.

bool QTextFormat::isImageFormat () const

Returns true if this text format is an image format; otherwise returns false.

bool QTextFormat::isListFormat () const

Returns true if this text format is a ListFormat; otherwise returns false.

bool QTextFormat::isTableFormat () const

Returns true if this text format is a TableFormat; otherwise returns false.

bool QTextFormat::isValid () const

Returns true if the format is valid (i.e. is not InvalidFormat); otherwise returns false.

QTextLength QTextFormat::lengthProperty ( int propertyId ) const

Returns the value of the property given by propertyId.

See also setProperty(), boolProperty(), intProperty(), floatProperty(), stringProperty(), colorProperty(), lengthVectorProperty(), and PropertyType.

QVector<QTextLength> QTextFormat::lengthVectorProperty ( int propertyId ) const

Returns the value of the property given by propertyId. If the property isn't of QTextFormat::LengthVector type, an empty length vector is returned instead.

See also setProperty(), boolProperty(), intProperty(), floatProperty(), stringProperty(), colorProperty(), lengthProperty(), and PropertyType.

void QTextFormat::merge ( const QTextFormat & other )

Merges the other format with this format; where there are conflicts the other format takes precedence.

int QTextFormat::objectIndex () const

Returns the index of the format object, or -1 if the format object is invalid.

See also setObjectIndex().

int QTextFormat::objectType () const

Returns the text format's object type. See ObjectTypes.

QMap<int, QVariant> QTextFormat::properties () const

Returns a map with all properties of this text format.

QVariant QTextFormat::property ( int propertyId ) const

Returns the property specified by the given propertyId.

void QTextFormat::setObjectIndex ( int index )

Sets the format object's object index.

See also objectIndex().

void QTextFormat::setObjectType ( int type )

Sets the text format's object type. See ObjectTypes.

void QTextFormat::setProperty ( int propertyId, const QVariant & value )

Sets the property specified by the propertyId to the given value.

void QTextFormat::setProperty ( int propertyId, const QString & value )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the value of the property given by propertyId to value.

See also stringProperty() and PropertyType.

void QTextFormat::setProperty ( int propertyId, const QColor & value )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the value of the property given by propertyId to value.

See also colorProperty() and PropertyType.

void QTextFormat::setProperty ( int propertyId, const QTextLength & value )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the value of the property given by propertyId to value.

See also lengthProperty() and PropertyType.

void QTextFormat::setProperty ( int propertyId, const QVector<QTextLength> & value )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the value of the property given by propertyId to value.

See also lengthVectorProperty() and PropertyType.

void QTextFormat::setProperty ( int propertyId, bool value )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the value of the property given by propertyId to value.

See also boolProperty() and PropertyType.

void QTextFormat::setProperty ( int propertyId, int value )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the value of the property given by propertyId to value.

See also intProperty() and PropertyType.

void QTextFormat::setProperty ( int propertyId, float value )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the value of the property given by propertyId to value.

See also floatProperty() and PropertyType.

QString QTextFormat::stringProperty ( int propertyId ) const

Returns the value of the property given by propertyId; if the property isn't of QTextFormat::String type, a null string is returned instead.

See also setProperty(), boolProperty(), intProperty(), floatProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), and PropertyType.

QTextBlockFormat QTextFormat::toBlockFormat () const

Returns this format as a block format.

QTextCharFormat QTextFormat::toCharFormat () const

Returns this format as a character format.

QTextFrameFormat QTextFormat::toFrameFormat () const

Returns this format as a frame format.

QTextImageFormat QTextFormat::toImageFormat () const

Returns this format as an image format.

QTextListFormat QTextFormat::toListFormat () const

Returns this format as a list format.

QTextTableFormat QTextFormat::toTableFormat () const

Returns this format as a table format.

int QTextFormat::type () const

Returns the type of this format.

See also ObjectTypes.

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

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

QTextFormat & QTextFormat::operator= ( const QTextFormat & other )

Assigns the other text format to this text format, and returns a reference to this text format.

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

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


Copyright © 2004 Trolltech Trademarks
Qt 4.0.0-b1