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

## com.trolltech.qt.gui
Class QTextBlock

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.gui.QTextBlock

All Implemented Interfaces:
  QtJambiInterface, java.lang.Comparable

    public class QTextBlock

extends QtJambiObject
implements java.lang.Comparable

The `QTextBlock` class provides a container for text fragments in a `QTextDocument`.

A text block encapsulates a block or paragraph of text in a `QTextDocument`. `QTextBlock` provides read-only access to the block/paragraph structure of QTextDocuments. It is mainly of use if you want to implement your own layouts for the visual representation of a `QTextDocument`, or if you want to iterate over a document and write out the contents in your own custom format.

Text blocks are created by their parent documents. If you need to create a new text block, or modify the contents of a document while examining its contents, use the cursor-based interface provided by `QTextCursor` instead.

Each text block is located at a specific `position` in a `document`. The contents of the block can be obtained by using the `text` function. The `length` function determines the block's size within the document (including formatting characters). The visual properties of the block are determined by its text `layout`, its `charFormat`, and its `blockFormat`.

The `next` and `previous` functions enable iteration over consecutive valid blocks in a document under the condition that the document is not modified by other means during the iteration process. Note that, although blocks are returned in sequence, adjacent blocks may come from different places in the document structure. The validity of a block can be determined by calling `isValid`.

`QTextBlock` provides comparison operators to make it easier to work with blocks: `operator==` compares two block for equality, `operator!=` compares two blocks for inequality, and `operator<` determines whether a block precedes another in the same document.

See Also:
  `QTextBlockFormat`, `QTextCharFormat`, `QTextFragment`

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>`

Constructor Summary
`QTextBlock()`
`QTextBlock(QTextBlock o)` Copies the `o` text block's attributes to this text block.

Method Summary
`QTextBlock_iterator` | `begin()` Returns a text block iterator pointing to the beginning of the text block.
`QTextBlockFormat` | `blockFormat()` Returns the `QTextBlockFormat` that describes block-specific properties.
`int` | `blockFormatIndex()` Returns an index into the document's internal list of block formats for the text block's format.
`QTextCharFormat` | `charFormat()` Returns the `QTextCharFormat` that describes the block's character format.
`int` | `charFormatIndex()` Returns an index into the document's internal list of character formats for the text block's character format.
`int` | `compareTo(java.lang.Object other)`
`boolean` | `contains(int position)` Returns true if the given `position` is located within the text block; otherwise returns false.
`QTextDocument` | `document()` Returns the text document this text block belongs to, or 0 if the text block does not belong to any document.
`QTextBlock_iterator` | `end()` Returns a text block iterator pointing to the end of the text block.
`boolean` | `equals(java.lang.Object other)`
`static QTextBlock` | `fromNativePointer(QNativePointer nativePointer)` This function returns the QTextBlock instance pointed to by nativePointer
`boolean` | `isValid()` Returns true if this text block is valid; otherwise returns false.
`QTextLayout` | `layout()` Returns the `QTextLayout` that is used to lay out and display the block's contents.
`int` | `length()` Returns the length of the block in characters.
`static QNativePointer` | `nativePointerArray(QTextBlock[] array)` This function returns a QNativePointer that is pointing to the specified QTextBlock array.
`QTextBlock` | `next()` Returns the text block in the document after this block, or an empty text block if this is the last one.
`int` | `position()` Returns the index of the block's first character within the document.
`QTextBlock` | `previous()` Returns the text block in the document before this block, or an empty text block if this is the first one.
`void` | `setUserData(QTextBlockUserData data)` Attaches the given `data` object to the text block.
`void` | `setUserState(int state)` Stores the specified `state` integer value in the text block.
`java.lang.String` | `text()` Returns the block's contents as plain text.
`QTextList` | `textList()` If the block represents a list item, returns the list that the item belongs to; otherwise returns 0.
`QTextBlockUserData` | `userData()` Returns a pointer to a `QTextBlockUserData` object if previously set with `setUserData` or a null pointer.
`int` | `userState()` Returns the integer value previously set with `setUserState` or -1.

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

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

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

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

Constructor Detail

### QTextBlock

    public QTextBlock()

### QTextBlock

    public QTextBlock(QTextBlock o)

  Copies the `o` text block's attributes to this text block.

Method Detail

### begin

    public final QTextBlock_iterator begin()

  Returns a text block iterator pointing to the beginning of the text block.

  See Also:
    `end`

### blockFormat

    public final QTextBlockFormat blockFormat()

  Returns the `QTextBlockFormat` that describes block-specific properties.

  See Also:
    `charFormat`

### blockFormatIndex

    public final int blockFormatIndex()

  Returns an index into the document's internal list of block formats for the text block's format.

  See Also:
    `QTextDocument::object`

### charFormat

    public final QTextCharFormat charFormat()

  Returns the `QTextCharFormat` that describes the block's character format. The block's character format is used when inserting text into an empty block.

  See Also:
    `blockFormat`

### charFormatIndex

    public final int charFormatIndex()

  Returns an index into the document's internal list of character formats for the text block's character format.

  See Also:
    `QTextDocument::object`

### contains

    public final boolean contains(int position)

  Returns true if the given `position` is located within the text block; otherwise returns false.

### document

    public final QTextDocument document()

  Returns the text document this text block belongs to, or 0 if the text block does not belong to any document.

### end

    public final QTextBlock_iterator end()

  Returns a text block iterator pointing to the end of the text block.

  See Also:
    `begin`, `next`, `previous`

### isValid

    public final boolean isValid()

  Returns true if this text block is valid; otherwise returns false.

### layout

    public final QTextLayout layout()

  Returns the `QTextLayout` that is used to lay out and display the block's contents.

  Note that the returned `QTextLayout` object can only be modified from the documentChanged implementation of a `QAbstractTextDocumentLayout` subclass. Any changes applied from the outside cause undefined behavior.

### length

    public final int length()

  Returns the length of the block in characters.

  See Also:
    `text`, `charFormat`, `blockFormat`

### next

    public final QTextBlock next()

  Returns the text block in the document after this block, or an empty text block if this is the last one.

  Note that the next block may be in a different frame or table to this block.

  See Also:
    `previous`, `begin`, `end`

### position

    public final int position()

  Returns the index of the block's first character within the document.

### previous

    public final QTextBlock previous()

  Returns the text block in the document before this block, or an empty text block if this is the first one.

  Note that the next block may be in a different frame or table to this block.

  See Also:
    `next`, `begin`, `end`

### setUserData

    public final void setUserData(QTextBlockUserData data)

  Attaches the given `data` object to the text block.

  `QTextBlockUserData` can be used to store custom settings. The ownership is passed to the underlying text document, i.e. the provided `QTextBlockUserData` object will be deleted if the corresponding text block gets deleted. The user data object is not stored in the undo history, so it will not be available after undoing the deletion of a text block.

  For example, if you write a programming editor in an IDE, you may want to let your user set breakpoints visually in your code for an integrated debugger. In a programming editor a line of text usually corresponds to one `QTextBlock`. The `QTextBlockUserData` interface allows the developer to store data for each `QTextBlock`, like for example in which lines of the source code the user has a breakpoint set. Of course this could also be stored externally, but by storing it inside the `QTextDocument`, it will for example be automatically deleted when the user deletes the associated line. It's really just a way to store custom information in the `QTextDocument` without using custom properties in `QTextFormat` which would affect the undo/redo stack.

  See Also:
    `userData`

### setUserState

    public final void setUserState(int state)

  Stores the specified `state` integer value in the text block. This may be useful for example in a syntax highlighter to store a text parsing state.

  See Also:
    `userState`

### text

    public final java.lang.String text()

  Returns the block's contents as plain text.

  See Also:
    `length`, `charFormat`, `blockFormat`

### textList

    public final QTextList textList()

  If the block represents a list item, returns the list that the item belongs to; otherwise returns 0.

### userData

    public final QTextBlockUserData userData()

  Returns a pointer to a `QTextBlockUserData` object if previously set with `setUserData` or a null pointer.

  See Also:
    `setUserData`

### userState

    public final int userState()

  Returns the integer value previously set with `setUserState` or -1.

  See Also:
    `setUserState`

### fromNativePointer

    public static QTextBlock fromNativePointer(QNativePointer nativePointer)

  This function returns the QTextBlock instance pointed to by nativePointer

  Parameters:
    `nativePointer` - the QNativePointer of which object should be returned.

### nativePointerArray

    public static QNativePointer nativePointerArray(QTextBlock[] array)

  This function returns a QNativePointer that is pointing to the specified QTextBlock array.

  Parameters:
    `array` - the array that the returned pointer will point to.
  Returns:
    a QNativePointer that is pointing to the specified array.

### equals

    public boolean equals(java.lang.Object other)

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

### compareTo

    public int compareTo(java.lang.Object other)

  Specified by:
    `compareTo` in interface `java.lang.Comparable`

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