# QTextDocument Class Reference

### [com.trolltech.qt.gui package]

Inherits QObject.

### Constructor

- void QTextDocument(QObject parent)
- void QTextDocument(String text, QObject parent)

### Constructor Properties

- prototype: The QTextDocument prototype object
- HtmlResource = 1
- ImageResource = 2
- StyleSheetResource = 3
- UserResource = 100
- ResourceType( value )
- UndoStack = 0x01
- RedoStack = 0x02
- UndoAndRedoStacks = UndoStack|RedoStack
- Stacks( value )
- FindBackward = 0x00001
- FindCaseSensitively = 0x00002
- FindWholeWords = 0x00004
- FindFlag( value )
- FindFlags( value1, value2, ... )
- DocumentTitle
- DocumentUrl
- MetaInformation( value )

### Prototype Object Properties

The QTextDocument prototype object inherits properties from the QObject prototype object and also has the following properties.

- void addResource(int type, QUrl name, Object resource)
- void adjustSize()
- List allFormats()
- int availableRedoSteps()
- int availableUndoSteps()
- QTextBlock begin()
- char characterAt(int pos)
- int characterCount()
- void clear()
- void clearUndoRedoStacks(Stacks historyToClear)
- QTextDocument clone(QObject parent)
- QTextOption defaultTextOption()
- QAbstractTextDocumentLayout documentLayout()
- void drawContents(QPainter painter, QRectF rect)
- QTextBlock end()
- QTextCursor find(QRegExp expr, QTextCursor from, FindFlags options)
- QTextBlock findBlock(int pos)
- QTextBlock findBlockByLineNumber(int blockNumber)
- QTextBlock findBlockByNumber(int blockNumber)
- QTextBlock firstBlock()
- QTextFrame frameAt(int pos)
- qreal idealWidth()
- bool isEmpty()
- bool isRedoAvailable()
- bool isUndoAvailable()
- QTextBlock lastBlock()
- int lineCount()
- void markContentsDirty(int from, int length)
- String metaInformation(MetaInformation info)
- QTextObject object(int objectIndex)
- QTextObject objectForFormat(QTextFormat arg__1)
- int pageCount()
- void print(QPrinter printer)
- void redo(QTextCursor cursor)
- Object resource(int type, QUrl name)
- int revision()
- QTextFrame rootFrame()
- void setDefaultTextOption(QTextOption option)
- void setDocumentLayout(QAbstractTextDocumentLayout layout)
- void setHtml(String html)
- void setMetaInformation(MetaInformation info, String arg__2)
- void setPlainText(String text)
- String toHtml(QByteArray encoding)
- String toPlainText()
- void undo(QTextCursor cursor)

### Instance Properties

QTextDocument objects inherit properties from the QTextDocument prototype object and also have the following properties.

- undoRedoEnabled
- modified
- pageSize
- defaultFont
- useDesignMetrics
- size
- textWidth
- blockCount
- indentWidth
- defaultStyleSheet
- maximumBlockCount
- documentMargin