Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QTextFormat

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.gui.QTextFormat

All Implemented Interfaces:
  QtJambiInterface, java.lang.Cloneable

Direct Known Subclasses:
  QTextBlockFormat, QTextCharFormat, QTextFrameFormat, QTextListFormat

    public class QTextFormat

extends QtJambiObject
implements java.lang.Cloneable

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.

Nested Class Summary
`static class` | `QTextFormat.FormatType`
`static class` | `QTextFormat.ObjectTypes`
`static class` | `QTextFormat.PageBreakFlag`
`static class` | `QTextFormat.PageBreakFlags`
`static class` | `QTextFormat.Property` Paragraph and character properties Paragraph properties Character properties List properties Table and frame properties Table cell properties Image properties Selection properties Page break properties

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QTextFormat()` Creates a new text format with an `InvalidFormat`.
`QTextFormat(int type)` Creates a new text format of the given `type`.
`QTextFormat(QTextFormat rhs)` Creates a new text format with the same attributes as the `other` text format.

Method Summary
`QBrush` | `background()` Returns the brush used to paint the document's background.
`boolean` | `boolProperty(int propertyId)` Returns the value of the property specified by `propertyId`.
`QBrush` | `brushProperty(int propertyId)` Returns the value of the property given by `propertyId`; if the property isn't of `QVariant::Brush` type, `Qt::NoBrush` is returned instead.
`void` | `clearBackground()` Clears the brush used to paint the document's background.
`void` | `clearForeground()` Clears the brush used to paint the document's foreground.
`void` | `clearProperty(int propertyId)` Clears the value of the property given by `propertyId`
`QTextFormat` | `clone()` This method is reimplemented for internal reasons
`QColor` | `colorProperty(int propertyId)` Returns the value of the property given by `propertyId`; if the property isn't of `QVariant::Color` type, an invalid color is returned instead.
`double` | `doubleProperty(int propertyId)` Returns the value of the property specified by `propertyId`.
`QBrush` | `foreground()` Returns the brush used to render foreground details, such as text, frame outlines, and table borders.
`boolean` | `hasProperty(int propertyId)` Returns true if the text format has a property with the given `propertyId`; otherwise returns false.
`int` | `intProperty(int propertyId)` Returns the value of the property specified by `propertyId`.
`boolean` | `isBlockFormat()` Returns true if this text format is a `BlockFormat`; otherwise returns false.
`boolean` | `isCharFormat()` Returns true if this text format is a `CharFormat`; otherwise returns false.
`boolean` | `isFrameFormat()` Returns true if this text format is a `FrameFormat`; otherwise returns false.
`boolean` | `isImageFormat()` Returns true if this text format is an image format; otherwise returns false.
`boolean` | `isListFormat()` Returns true if this text format is a `ListFormat`; otherwise returns false.
`boolean` | `isTableCellFormat()` Returns true if this text format is a `TableCellFormat`; otherwise returns false.
`boolean` | `isTableFormat()` Returns true if this text format is a `TableFormat`; otherwise returns false.
`boolean` | `isValid()` Returns true if the format is valid (i.
`Qt.LayoutDirection` | `layoutDirection()` Returns the document's layout direction.
`QTextLength` | `lengthProperty(int propertyId)` Returns the value of the property given by `propertyId`.
`java.util.List` | `lengthVectorProperty(int propertyId)` Returns the value of the property given by `propertyId`.
`void` | `merge(QTextFormat other)` Merges the `other` format with this format; where there are conflicts the `other` format takes precedence.
`int` | `objectIndex()` Returns the index of the format object, or -1 if the format object is invalid.
`int` | `objectType()` Returns the text format's object type.
`QPen` | `penProperty(int propertyId)` Returns the value of the property given by `propertyId`; if the property isn't of `QVariant::Pen` type, `Qt::NoPen` is returned instead.
`java.util.SortedMap` | `properties()` Returns a map with all properties of this text format.
`java.lang.Object` | `property(int propertyId)` Returns the property specified by the given `propertyId`.
`int` | `propertyCount()` Returns the number of properties stored in the format.
`void` | `readFrom(QDataStream arg__1)` Reads a QTextFormat
`void` | `setBackground(QBrush brush)` Sets the brush use to paint the document's background to the `brush` specified.
`void` | `setForeground(QBrush brush)` Sets the foreground brush to the specified `brush`.
`void` | `setLayoutDirection(Qt.LayoutDirection direction)` Sets the document's layout direction to the specified `direction`.
`void` | `setObjectIndex(int object)` Sets the format object's object `index`.
`void` | `setObjectType(int type)` Sets the text format's object `type`.
`void` | `setProperty(int propertyId, java.util.List lengths)` Sets the value of the property given by `propertyId` to `value`.
`void` | `setProperty(int propertyId, java.lang.Object value)` Sets the property specified by the `propertyId` to the given `value`.
`java.lang.String` | `stringProperty(int propertyId)` Returns the value of the property given by `propertyId`; if the property isn't of `QVariant::String` type, an empty string is returned instead.
`QTextBlockFormat` | `toBlockFormat()` Returns this format as a block format.
`QTextCharFormat` | `toCharFormat()` Returns this format as a character format.
`QTextFrameFormat` | `toFrameFormat()` Returns this format as a frame format.
`QTextImageFormat` | `toImageFormat()` Returns this format as an image format.
`QTextListFormat` | `toListFormat()` Returns this format as a list format.
`QTextTableCellFormat` | `toTableCellFormat()` Returns this format as a table cell format.
`QTextTableFormat` | `toTableFormat()` Returns this format as a table format.
`int` | `type()` Returns the type of this format.
`void` | `writeTo(QDataStream arg__1)` Writes thisQTextFormat

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QTextFormat

    public QTextFormat()

  Creates a new text format with an `InvalidFormat`.

See also:
  `FormatType` .

### QTextFormat

    public QTextFormat(QTextFormat rhs)

  Creates a new text format with the same attributes as the `other` text format.

### QTextFormat

    public QTextFormat(int type)

  Creates a new text format of the given `type`.

See also:
  `FormatType` .

Method Detail

### background

    public final QBrush background()

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

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

### boolProperty

    public final boolean boolProperty(int propertyId)

  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` .

### brushProperty

    public final QBrush brushProperty(int propertyId)

  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` .

### clearBackground

    public final void clearBackground()

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

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

### clearForeground

    public final void clearForeground()

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

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

### clearProperty

    public final void clearProperty(int propertyId)

  Clears the value of the property given by `propertyId`

### colorProperty

    public final QColor colorProperty(int propertyId)

  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` .

### doubleProperty

    public final double doubleProperty(int propertyId)

  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` .

### foreground

    public final QBrush foreground()

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

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

### hasProperty

    public final boolean hasProperty(int propertyId)

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

See also:
  `properties()`, and `Property` .

### intProperty

    public final int intProperty(int propertyId)

  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` .

### isBlockFormat

    public final boolean isBlockFormat()

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

### isCharFormat

    public final boolean isCharFormat()

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

### isFrameFormat

    public final boolean isFrameFormat()

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

### isImageFormat

    public final boolean isImageFormat()

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

### isListFormat

    public final boolean isListFormat()

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

### isTableCellFormat

    public final boolean isTableCellFormat()

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

### isTableFormat

    public final boolean isTableFormat()

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

### isValid

    public boolean isValid()

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

### layoutDirection

    public final Qt.LayoutDirection layoutDirection()

  Returns the document's layout direction.

See also:
  `setLayoutDirection()`.

### lengthProperty

    public final QTextLength lengthProperty(int propertyId)

  Returns the value of the property given by `propertyId`.

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

### lengthVectorProperty

    public final java.util.List lengthVectorProperty(int propertyId)

  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` .

### merge

    public final void merge(QTextFormat other)

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

### objectIndex

    public final int objectIndex()

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

See also:
  `setObjectIndex()`.

### objectType

    public final int objectType()

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

See also:
  `setObjectType()`.

### writeTo

    public final void writeTo(QDataStream arg__1)

  Writes thisQTextFormat

### readFrom

    public final void readFrom(QDataStream arg__1)

  Reads a QTextFormat

### penProperty

    public final QPen penProperty(int propertyId)

  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` .

### properties

    public final java.util.SortedMap properties()

  Returns a map with all properties of this text format.

### property

    public final java.lang.Object property(int propertyId)

  Returns the property specified by the given `propertyId`.

See also:
  `setProperty()`.

### propertyCount

    public final int propertyCount()

  Returns the number of properties stored in the format.

### setBackground

    public final void setBackground(QBrush brush)

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

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

### setForeground

    public final void setForeground(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()`.

### setLayoutDirection

    public final void setLayoutDirection(Qt.LayoutDirection direction)

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

See also:
  `layoutDirection()`.

### setObjectIndex

    public final void setObjectIndex(int object)

  Sets the format object's object `index`.

See also:
  `objectIndex()`.

### setObjectType

    public final void setObjectType(int type)

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

See also:
  `objectType()`.

### setProperty

    public final void setProperty(int propertyId,
                                  java.lang.Object value)

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

See also:
  `property()`.

### setProperty

    public final void setProperty(int propertyId,
                                  java.util.List lengths)

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

See also:
  `lengthVectorProperty()`, and `Property` .

### stringProperty

    public final java.lang.String stringProperty(int propertyId)

  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` .

### toBlockFormat

    public final QTextBlockFormat toBlockFormat()

  Returns this format as a block format.

### toCharFormat

    public final QTextCharFormat toCharFormat()

  Returns this format as a character format.

### toFrameFormat

    public final QTextFrameFormat toFrameFormat()

  Returns this format as a frame format.

### toImageFormat

    public final QTextImageFormat toImageFormat()

  Returns this format as an image format.

### toListFormat

    public final QTextListFormat toListFormat()

  Returns this format as a list format.

### toTableCellFormat

    public final QTextTableCellFormat toTableCellFormat()

  Returns this format as a table cell format.

### toTableFormat

    public final QTextTableFormat toTableFormat()

  Returns this format as a table format.

### type

    public final int type()

  Returns the type of this format.

See also:
  `FormatType` .

### clone

    public QTextFormat clone()

  This method is reimplemented for internal reasons

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD