Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QTextFormat Class Reference

Inheritance diagram for QTextFormat:

QTextBlockFormat QTextCharFormat QTextFrameFormat QTextListFormat QTextImageFormat QTextTableFormat

List of all members.

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 corresponding Property.

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(), doubleProperty(), 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:
{Text Processing Classes}

Definition at line 123 of file qtextformat.h.

Public Types

enum  FormatType {
  InvalidFormat = -1, BlockFormat = 1, CharFormat = 2, ListFormat = 3,
  TableFormat = 4, FrameFormat = 5, UserFormat = 100
enum  ObjectTypes { NoObject, ImageObject, TableObject, UserObject = 0x1000 }
enum  PageBreakFlag { PageBreak_Auto = 0, PageBreak_AlwaysBefore = 0x001, PageBreak_AlwaysAfter = 0x010 }
enum  Property {
  ObjectIndex = 0x0, CssFloat = 0x0800, LayoutDirection = 0x0801, OutlinePen = 0x810,
  BackgroundBrush = 0x820, ForegroundBrush = 0x821, BlockAlignment = 0x1010, BlockTopMargin = 0x1030,
  BlockBottomMargin = 0x1031, BlockLeftMargin = 0x1032, BlockRightMargin = 0x1033, TextIndent = 0x1034,
  BlockIndent = 0x1040, BlockNonBreakableLines = 0x1050, BlockTrailingHorizontalRulerWidth = 0x1060, FontFamily = 0x2000,
  FontPointSize = 0x2001, FontSizeAdjustment = 0x2002, FontSizeIncrement = FontSizeAdjustment, FontWeight = 0x2003,
  FontItalic = 0x2004, FontUnderline = 0x2005, FontOverline = 0x2006, FontStrikeOut = 0x2007,
  FontFixedPitch = 0x2008, FontPixelSize = 0x2009, TextUnderlineColor = 0x2010, TextVerticalAlignment = 0x2021,
  TextOutline = 0x2022, TextUnderlineStyle = 0x2023, TextToolTip = 0x2024, IsAnchor = 0x2030,
  AnchorHref = 0x2031, AnchorName = 0x2032, ObjectType = 0x2f00, ListStyle = 0x3000,
  ListIndent = 0x3001, FrameBorder = 0x4000, FrameMargin = 0x4001, FramePadding = 0x4002,
  FrameWidth = 0x4003, FrameHeight = 0x4004, FrameTopMargin = 0x4005, FrameBottomMargin = 0x4006,
  FrameLeftMargin = 0x4007, FrameRightMargin = 0x4008, FrameBorderBrush = 0x4009, FrameBorderStyle = 0x4010,
  TableColumns = 0x4100, TableColumnWidthConstraints = 0x4101, TableCellSpacing = 0x4102, TableCellPadding = 0x4103,
  TableHeaderRowCount = 0x4104, TableCellRowSpan = 0x4810, TableCellColumnSpan = 0x4811, ImageName = 0x5000,
  ImageWidth = 0x5010, ImageHeight = 0x5011, FullWidthSelection = 0x06000, PageBreakPolicy = 0x7000,
  UserProperty = 0x100000

Public Member Functions

QBrush background () const
bool boolProperty (int propertyId) const
QBrush brushProperty (int propertyId) const
void clearBackground ()
void clearForeground ()
void clearProperty (int propertyId)
QColor colorProperty (int propertyId) const
qreal doubleProperty (int propertyId) const
QBrush foreground () const
bool hasProperty (int propertyId) const
int intProperty (int propertyId) const
bool isBlockFormat () const
bool isCharFormat () const
bool isFrameFormat () const
bool isImageFormat () const
bool isListFormat () const
bool isTableFormat () const
bool isValid () const
Qt::LayoutDirection layoutDirection () const
QTextLength lengthProperty (int propertyId) const
QVector< QTextLengthlengthVectorProperty (int propertyId) const
void merge (const QTextFormat &other)
int objectIndex () const
int objectType () const
 operator QVariant () const
bool operator!= (const QTextFormat &rhs) const
QTextFormatoperator= (const QTextFormat &rhs)
bool operator== (const QTextFormat &rhs) const
QPen penProperty (int propertyId) const
QMap< int, QVariantproperties () const
QVariant property (int propertyId) const
int propertyCount () const
 QTextFormat (const QTextFormat &rhs)
 QTextFormat (int type)
 QTextFormat ()
void setBackground (const QBrush &brush)
void setForeground (const QBrush &brush)
void setLayoutDirection (Qt::LayoutDirection direction)
void setObjectIndex (int object)
void setObjectType (int type)
void setProperty (int propertyId, const QVector< QTextLength > &lengths)
void setProperty (int propertyId, const QVariant &value)
QString stringProperty (int propertyId) const
QTextBlockFormat toBlockFormat () const
QTextCharFormat toCharFormat () const
QTextFrameFormat toFrameFormat () const
QTextImageFormat toImageFormat () const
QTextListFormat toListFormat () const
QTextTableFormat toTableFormat () const
int type () const
 ~QTextFormat ()

Private Attributes

< QTextFormatPrivate > 
qint32 format_type


Q_GUI_EXPORT QDataStreamoperator<< (QDataStream &, const QTextFormat &)
Q_GUI_EXPORT QDataStreamoperator>> (QDataStream &, QTextFormat &)
class QTextCharFormat
class QTextFormatCollection

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

Generated by  Doxygen 1.6.0   Back to index