Qt:Документация 4.3.2/qtextformat

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QTextFormat Class Reference
[модуль QtGui ]

The QTextFormat class provides formatting information for a QTextDocument. Далее...

 #include <QTextFormat>

Inherited by QTextBlockFormat, QTextCharFormat, QTextFrameFormat, and QTextListFormat.

[править] Открытые типы

  • enum FormatType { InvalidFormat, BlockFormat, CharFormat, ListFormat, ..., UserFormat }
  • enum ObjectTypes { NoObject, ImageObject, TableObject, UserObject }
  • enum PageBreakFlag { PageBreak_Auto, PageBreak_AlwaysBefore, PageBreak_AlwaysAfter }
  • flags PageBreakFlags
  • enum Property { ObjectIndex, CssFloat, LayoutDirection, OutlinePen, ..., UserProperty }

[править] Открытые функции


[править] Подробное описание

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.


[править] Описание типов

[править]
enum QTextFormat::FormatType

Константа Значение
QTextFormat::InvalidFormat -1
QTextFormat::BlockFormat 1
QTextFormat::CharFormat 2
QTextFormat::ListFormat 3
QTextFormat::TableFormat 4
QTextFormat::FrameFormat 5
QTextFormat::UserFormat 100

[править]
enum QTextFormat::ObjectTypes

Константа Значение Описание
QTextFormat::NoObject 0
QTextFormat::ImageObject 1
QTextFormat::TableObject 2
QTextFormat::UserObject 0x1000 The first object that can be used for application-specific purposes.

[править]
enum QTextFormat::PageBreakFlag
flags QTextFormat::PageBreakFlags

Константа Значение Описание
QTextFormat::PageBreak_Auto 0 The page break is determined automatically depending on the available space on the current page
QTextFormat::PageBreak_AlwaysBefore 0x001 The page is always broken before the paragraph/table
QTextFormat::PageBreak_AlwaysAfter 0x010 A new page is always started after the paragraph/table

This enum was introduced in Qt 4.2.

The PageBreakFlags type is a typedef for QFlags<PageBreakFlag>. It stores an OR combination of PageBreakFlag values.

[править]
enum QTextFormat::Property

Константа Значение
QTextFormat::ObjectIndex 0x0

Paragraph and character properties


Константа Значение Описание
QTextFormat::CssFloat 0x0800
QTextFormat::LayoutDirection 0x0801 The layout direction of the text in the document ( Qt::LayoutDirection).
QTextFormat::OutlinePen 0x810
QTextFormat::ForegroundBrush 0x821
QTextFormat::BackgroundBrush 0x820

Paragraph properties


Константа Значение
QTextFormat::BlockAlignment 0x1010
QTextFormat::BlockTopMargin 0x1030
QTextFormat::BlockBottomMargin 0x1031
QTextFormat::BlockLeftMargin 0x1032
QTextFormat::BlockRightMargin 0x1033
QTextFormat::TextIndent 0x1034
QTextFormat::BlockIndent 0x1040
QTextFormat::BlockNonBreakableLines 0x1050
QTextFormat::BlockTrailingHorizontalRulerWidth 0x1060

Character properties


Константа Значение Описание
QTextFormat::FontFamily 0x2000
QTextFormat::FontPointSize 0x2001
QTextFormat::FontSizeIncrement FontSizeAdjustment
QTextFormat::FontWeight 0x2003
QTextFormat::FontItalic 0x2004
QTextFormat::FontUnderline 0x2005 This property has been deprecated. Use QTextFormat::TextUnderlineStyle instead.
QTextFormat::FontOverline 0x2006
QTextFormat::FontStrikeOut 0x2007
QTextFormat::FontFixedPitch 0x2008
QTextFormat::FontPixelSize 0x2009
QTextFormat::TextUnderlineColor 0x2010
QTextFormat::TextVerticalAlignment 0x2021
QTextFormat::TextOutline 0x2022
QTextFormat::TextUnderlineStyle 0x2023
QTextFormat::TextToolTip 0x2024 Specifies the (optional) tool tip to be displayed for a fragment of text.
QTextFormat::IsAnchor 0x2030
QTextFormat::AnchorHref 0x2031
QTextFormat::AnchorName 0x2032
QTextFormat::ObjectType 0x2f00

List properties


Константа Значение
QTextFormat::ListStyle 0x3000
QTextFormat::ListIndent 0x3001

Table and frame properties


Константа Значение
QTextFormat::FrameBorder 0x4000
QTextFormat::FrameBorderBrush 0x4009
QTextFormat::FrameBorderStyle 0x4010
QTextFormat::FrameBottomMargin 0x4006
QTextFormat::FrameHeight 0x4004
QTextFormat::FrameLeftMargin 0x4007
QTextFormat::FrameMargin 0x4001
QTextFormat::FramePadding 0x4002
QTextFormat::FrameRightMargin 0x4008
QTextFormat::FrameTopMargin 0x4005
QTextFormat::FrameWidth 0x4003
QTextFormat::TableCellSpacing 0x4102
QTextFormat::TableCellPadding 0x4103
QTextFormat::TableColumns 0x4100
QTextFormat::TableColumnWidthConstraints 0x4101
QTextFormat::TableHeaderRowCount 0x4104

Table cell properties


Константа Значение
QTextFormat::TableCellRowSpan 0x4810
QTextFormat::TableCellColumnSpan 0x4811

Image properties


Константа Значение
QTextFormat::ImageName 0x5000
QTextFormat::ImageWidth 0x5010
QTextFormat::ImageHeight 0x5011

Selection properties


Константа Значение
QTextFormat::FullWidthSelection 0x06000

Page break properties


Константа Значение
QTextFormat::PageBreakPolicy 0x7000
QTextFormat::UserProperty 0x100000

[править] Описание функций-членов

[править]
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 as the other text format.

[править]
QTextFormat::~QTextFormat ()

Destroys this text format.

[править]
QBrush QTextFormat::background () const

Returns the brush used to paint the document's background.

See also setBackground(), clearBackground(), and foreground().

[править]
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(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), and Property.

[править]
QBrush QTextFormat::brushProperty ( int propertyId ) const

Returns the value of the property given by propertyId; if the property isn't of QVariant::Brush type, Qt::NoBrush is returned instead.

See also setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), and Property.

[править]
void QTextFormat::clearBackground ()

Clears the brush used to paint the document's background. The default brush will be used.

See also background(), setBackground(), and clearForeground().

[править]
void QTextFormat::clearForeground ()

Clears the brush used to paint the document's foreground. The default brush will be used.

See also foreground(), setForeground(), and clearBackground().

[править]
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 QVariant::Color type, an invalid color is returned instead.

See also setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), and Property.

[править]
qreal QTextFormat::doubleProperty ( int propertyId ) const

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

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

[править]
QBrush QTextFormat::foreground () const

Returns the brush used to render foreground details, such as text, frame outlines, and table borders.

See also setForeground(), clearForeground(), and background().

[править]
bool QTextFormat::hasProperty ( int propertyId ) const

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

See also properties() and Property.

[править]
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(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), and Property.

[править]
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.

[править]
Qt::LayoutDirection QTextFormat::layoutDirection () const

Returns the document's layout direction.

See also setLayoutDirection().

[править]
QTextLength QTextFormat::lengthProperty ( int propertyId ) const

Returns the value of the property given by propertyId.

See also setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), colorProperty(), lengthVectorProperty(), and Property.

[править]
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(), doubleProperty(), stringProperty(), colorProperty(), lengthProperty(), and Property.

[править]
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.

See also setObjectType().

[править]
QPen QTextFormat::penProperty ( int propertyId ) const

Returns the value of the property given by propertyId; if the property isn't of QVariant::Pen type, Qt::NoPen is returned instead.

See also setProperty(), boolProperty(), intProperty(), doubleProperty(), stringProperty(), lengthProperty(), lengthVectorProperty(), and Property.

[править]
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.

See also setProperty().

[править]
int QTextFormat::propertyCount () const

Returns the number of properties stored in the format.

Эта функция была введена в Qt 4.3.

[править]
void QTextFormat::setBackground ( const QBrush & brush )

Sets the brush use to paint the document's background to the brush specified.

See also background(), clearBackground(), and setForeground().

[править]
void QTextFormat::setForeground ( const QBrush & brush )

Sets the foreground brush to the specified brush. The foreground brush is mostly used to render text.

See also foreground(), clearForeground(), and setBackground().

[править]
void QTextFormat::setLayoutDirection ( Qt::LayoutDirection direction )

Sets the document's layout direction to the specified direction.

See also layoutDirection().

[править]
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.

See also objectType().

[править]
void QTextFormat::setProperty ( int propertyId, const QVariant & value )

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

See also property().

[править]
void QTextFormat::setProperty ( int propertyId, const QVector< QTextLength> & value )

Эта перегруженная функция предоставлена для удобства.

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

See also lengthVectorProperty() and Property.

[править]
QString QTextFormat::stringProperty ( int propertyId ) const

Returns the value of the property given by propertyId; if the property isn't of QVariant::String type, an empty string is returned instead.

See also setProperty(), boolProperty(), intProperty(), doubleProperty(), colorProperty(), lengthProperty(), lengthVectorProperty(), and Property.

[править]
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.

[править]
QTextFormat::operator QVariant () const

Returns the text format as a QVariant

[править]
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 © 2007 Trolltech Trademarks
Qt 4.3.2