[][src]Struct qt_gui::QTextDocument

#[repr(C)]
pub struct QTextDocument { /* fields omitted */ }

The QTextDocument class holds formatted text.

C++ class: QTextDocument.

C++ documentation:

The QTextDocument class holds formatted text.

QTextDocument is a container for structured rich text documents, providing support for styled text and various types of document elements, such as lists, tables, frames, and images. They can be created for use in a QTextEdit, or used independently.

Each document element is described by an associated format object. Each format object is treated as a unique object by QTextDocuments, and can be passed to objectForFormat() to obtain the document element that it is applied to.

A QTextDocument can be edited programmatically using a QTextCursor, and its contents can be examined by traversing the document structure. The entire document structure is stored as a hierarchy of document elements beneath the root frame, found with the rootFrame() function. Alternatively, if you just want to iterate over the textual contents of the document you can use begin(), end(), and findBlock() to retrieve text blocks that you can examine and iterate over.

The layout of a document is determined by the documentLayout(); you can create your own QAbstractTextDocumentLayout subclass and set it using setDocumentLayout() if you want to use your own layout logic. The document's title and other meta-information can be obtained by calling the metaInformation() function. For documents that are exposed to users through the QTextEdit class, the document title is also available via the QTextEdit::documentTitle() function.

The toPlainText() and toHtml() convenience functions allow you to retrieve the contents of the document as plain text and HTML. The document's text can be searched using the find() functions.

Undo/redo of operations performed on the document can be controlled using the setUndoRedoEnabled() function. The undo/redo system can be controlled by an editor widget through the undo() and redo() slots; the document also provides contentsChanged(), undoAvailable(), and redoAvailable() signals that inform connected editor widgets about the state of the undo/redo system. The following are the undo/redo operations of a QTextDocument:

  • Insertion or removal of characters. A sequence of insertions or removals within the same text block are regarded as a single undo/redo operation.
  • Insertion or removal of text blocks. Sequences of insertion or removals in a single operation (e.g., by selecting and then deleting text) are regarded as a single undo/redo operation.
  • Text character format changes.
  • Text block format changes.
  • Text block group format changes.

Methods

impl QTextDocument[src]

pub fn contents_change(&self) -> Signal<(c_int, c_int, c_int)>[src]

This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.

Returns a built-in Qt signal QTextDocument::contentsChange that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.

Information is provided about the position of the character in the document where the change occurred, the number of characters removed (charsRemoved), and the number of characters added (charsAdded).

The signal is emitted before the document's layout manager is notified about the change. This hook allows you to implement syntax highlighting for the document.

See also QAbstractTextDocumentLayout::documentChanged() and contentsChanged().

pub fn contents_changed(&self) -> Signal<()>[src]

This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.

Returns a built-in Qt signal QTextDocument::contentsChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.

See also contentsChange().

pub fn undo_available(&self) -> Signal<(bool,)>[src]

This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).

Returns a built-in Qt signal QTextDocument::undoAvailable that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).

See the Qt Undo Framework documentation for details.

See also undo() and isUndoRedoEnabled().

pub fn redo_available(&self) -> Signal<(bool,)>[src]

This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).

Returns a built-in Qt signal QTextDocument::redoAvailable that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).

pub fn undo_command_added(&self) -> Signal<()>[src]

This signal is emitted every time a new level of undo is added to the QTextDocument.

Returns a built-in Qt signal QTextDocument::undoCommandAdded that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted every time a new level of undo is added to the QTextDocument.

This function was introduced in Qt 4.4.

pub fn modification_changed(&self) -> Signal<(bool,)>[src]

This signal is emitted whenever the content of the document changes in a way that affects the modification state. If changed is true, the document has been modified; otherwise it is false.

Returns a built-in Qt signal QTextDocument::modificationChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever the content of the document changes in a way that affects the modification state. If changed is true, the document has been modified; otherwise it is false.

For example, calling setModified(false) on a document and then inserting text causes the signal to get emitted. If you undo that operation, causing the document to return to its original unmodified state, the signal will get emitted again.

pub fn cursor_position_changed(&self) -> Signal<(*const QTextCursor,)>[src]

This signal is emitted whenever the position of a cursor changed due to an editing operation. The cursor that changed is passed in cursor. If the document is used with the QTextEdit class and you need a signal when the cursor is moved with the arrow keys you can use the cursorPositionChanged() signal in QTextEdit.

Returns a built-in Qt signal QTextDocument::cursorPositionChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted whenever the position of a cursor changed due to an editing operation. The cursor that changed is passed in cursor. If the document is used with the QTextEdit class and you need a signal when the cursor is moved with the arrow keys you can use the cursorPositionChanged() signal in QTextEdit.

pub fn block_count_changed(&self) -> Signal<(c_int,)>[src]

This signal is emitted when the total number of text blocks in the document changes. The value passed in newBlockCount is the new total.

Returns a built-in Qt signal QTextDocument::blockCountChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when the total number of text blocks in the document changes. The value passed in newBlockCount is the new total.

This function was introduced in Qt 4.3.

pub fn base_url_changed(&self) -> Signal<(*const QUrl,)>[src]

This property holds the base URL used to resolve relative resource URLs within the document.

Returns a built-in Qt signal QTextDocument::baseUrlChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds the base URL used to resolve relative resource URLs within the document.

Resource URLs are resolved to be within the same directory as the target of the base URL meaning any portion of the path after the last '/' will be ignored.

Base URLRelative URLResolved URL
file:///path/to/contentimages/logo.pngfile:///path/to/images/logo.png
file:///path/to/content/images/logo.pngfile:///path/to/content/images/logo.png
file:///path/to/content/index.htmlimages/logo.pngfile:///path/to/content/images/logo.png
file:///path/to/content/images/../images/logo.pngfile:///path/to/content/images/logo.png

This property was introduced in Qt 5.3.

Access functions:

QUrl baseUrl() const
void setBaseUrl(const QUrl &url)

Notifier signal:

void baseUrlChanged(const QUrl &url)

pub fn document_layout_changed(&self) -> Signal<()>[src]

This signal is emitted when a new document layout is set.

Returns a built-in Qt signal QTextDocument::documentLayoutChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when a new document layout is set.

This function was introduced in Qt 4.4.

See also setDocumentLayout().

pub fn slot_undo(&self) -> Receiver<()>[src]

This is an overloaded function.

Returns a built-in Qt slot QTextDocument::undo that can be passed to qt_core::Signal::connect.

C++ documentation:

This is an overloaded function.

pub fn slot_redo(&self) -> Receiver<()>[src]

This is an overloaded function.

Returns a built-in Qt slot QTextDocument::redo that can be passed to qt_core::Signal::connect.

C++ documentation:

This is an overloaded function.

Redoes the last editing operation on the document if redo is available.

pub fn slot_append_undo_item(&self) -> Receiver<(*mut QAbstractUndoItem,)>[src]

Returns a built-in Qt slot QTextDocument::appendUndoItem that can be passed to qt_core::Signal::connect.

pub fn slot_set_modified(&self) -> Receiver<(bool,)>[src]

This property holds whether the document has been modified by the user

Returns a built-in Qt slot QTextDocument::setModified that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds whether the document has been modified by the user

By default, this property is false.

Access functions:

bool isModified() const
void setModified(bool m = true)

See also modificationChanged().

pub unsafe fn add_resource(
    &mut self,
    type_: c_int,
    name: impl CastInto<Ref<QUrl>>,
    resource: impl CastInto<Ref<QVariant>>
)
[src]

Adds the resource resource to the resource cache, using type and name as identifiers. type should be a value from QTextDocument::ResourceType.

Calls C++ function: void QTextDocument::addResource(int type, const QUrl& name, const QVariant& resource).

C++ documentation:

Adds the resource resource to the resource cache, using type and name as identifiers. type should be a value from QTextDocument::ResourceType.

For example, you can add an image as a resource in order to reference it from within the document:

document->addResource(QTextDocument::ImageResource, QUrl("mydata://image.png"), QVariant(image));

The image can be inserted into the document using the QTextCursor API:

QTextImageFormat imageFormat; imageFormat.setName("mydata://image.png"); cursor.insertImage(imageFormat);

Alternatively, you can insert images using the HTML img tag:

editor->append("<img src="mydata://image.png" />");

pub unsafe fn adjust_size(&mut self)[src]

Adjusts the document to a reasonable size.

Calls C++ function: void QTextDocument::adjustSize().

C++ documentation:

Adjusts the document to a reasonable size.

This function was introduced in Qt 4.2.

See also idealWidth(), textWidth, and size.

pub unsafe fn all_formats(&self) -> CppBox<QVectorOfQTextFormat>[src]

Returns a vector of text formats for all the formats used in the document.

Calls C++ function: QVector<QTextFormat> QTextDocument::allFormats() const.

C++ documentation:

Returns a vector of text formats for all the formats used in the document.

pub unsafe fn append_undo_item(
    &mut self,
    arg1: impl CastInto<MutPtr<QAbstractUndoItem>>
)
[src]

Calls C++ function: [slot] void QTextDocument::appendUndoItem(QAbstractUndoItem* arg1).

pub unsafe fn available_redo_steps(&self) -> c_int[src]

Returns the number of available redo steps.

Calls C++ function: int QTextDocument::availableRedoSteps() const.

C++ documentation:

Returns the number of available redo steps.

This function was introduced in Qt 4.6.

See also isRedoAvailable().

pub unsafe fn available_undo_steps(&self) -> c_int[src]

Returns the number of available undo steps.

Calls C++ function: int QTextDocument::availableUndoSteps() const.

C++ documentation:

Returns the number of available undo steps.

This function was introduced in Qt 4.6.

See also isUndoAvailable().

pub unsafe fn base_url(&self) -> CppBox<QUrl>[src]

This property holds the base URL used to resolve relative resource URLs within the document.

Calls C++ function: QUrl QTextDocument::baseUrl() const.

C++ documentation:

This property holds the base URL used to resolve relative resource URLs within the document.

Resource URLs are resolved to be within the same directory as the target of the base URL meaning any portion of the path after the last '/' will be ignored.

Base URLRelative URLResolved URL
file:///path/to/contentimages/logo.pngfile:///path/to/images/logo.png
file:///path/to/content/images/logo.pngfile:///path/to/content/images/logo.png
file:///path/to/content/index.htmlimages/logo.pngfile:///path/to/content/images/logo.png
file:///path/to/content/images/../images/logo.pngfile:///path/to/content/images/logo.png

This property was introduced in Qt 5.3.

Access functions:

QUrl baseUrl() const
void setBaseUrl(const QUrl &url)

Notifier signal:

void baseUrlChanged(const QUrl &url)

pub unsafe fn begin(&self) -> CppBox<QTextBlock>[src]

Returns the document's first text block.

Calls C++ function: QTextBlock QTextDocument::begin() const.

C++ documentation:

Returns the document's first text block.

See also firstBlock().

pub unsafe fn block_count(&self) -> c_int[src]

Returns the number of text blocks in the document.

Calls C++ function: int QTextDocument::blockCount() const.

C++ documentation:

Returns the number of text blocks in the document.

The value of this property is undefined in documents with tables or frames.

By default, if defined, this property contains a value of 1.

This property was introduced in Qt 4.2.

Access functions:

int blockCount() const

See also lineCount() and characterCount().

pub unsafe fn character_at(&self, pos: c_int) -> CppBox<QChar>[src]

Returns the character at position pos, or a null character if the position is out of range.

Calls C++ function: QChar QTextDocument::characterAt(int pos) const.

C++ documentation:

Returns the character at position pos, or a null character if the position is out of range.

This function was introduced in Qt 4.5.

See also characterCount().

pub unsafe fn character_count(&self) -> c_int[src]

Returns the number of characters of this document.

Calls C++ function: int QTextDocument::characterCount() const.

C++ documentation:

Returns the number of characters of this document.

This function was introduced in Qt 4.5.

See also blockCount() and characterAt().

pub unsafe fn clear(&mut self)[src]

Clears the document.

Calls C++ function: virtual void QTextDocument::clear().

C++ documentation:

Clears the document.

pub unsafe fn clear_undo_redo_stacks_1a(&mut self, history_to_clear: Stacks)[src]

Clears the stacks specified by stacksToClear.

Calls C++ function: void QTextDocument::clearUndoRedoStacks(QTextDocument::Stacks historyToClear = …).

C++ documentation:

Clears the stacks specified by stacksToClear.

This method clears any commands on the undo stack, the redo stack, or both (the default). If commands are cleared, the appropriate signals are emitted, QTextDocument::undoAvailable() or QTextDocument::redoAvailable().

This function was introduced in Qt 4.7.

See also QTextDocument::undoAvailable() and QTextDocument::redoAvailable().

pub unsafe fn clear_undo_redo_stacks_0a(&mut self)[src]

Clears the stacks specified by stacksToClear.

Calls C++ function: void QTextDocument::clearUndoRedoStacks().

C++ documentation:

Clears the stacks specified by stacksToClear.

This method clears any commands on the undo stack, the redo stack, or both (the default). If commands are cleared, the appropriate signals are emitted, QTextDocument::undoAvailable() or QTextDocument::redoAvailable().

This function was introduced in Qt 4.7.

See also QTextDocument::undoAvailable() and QTextDocument::redoAvailable().

pub unsafe fn clone_1a(
    &self,
    parent: impl CastInto<MutPtr<QObject>>
) -> MutPtr<QTextDocument>
[src]

Creates a new QTextDocument that is a copy of this text document. parent is the parent of the returned text document.

Calls C++ function: QTextDocument* QTextDocument::clone(QObject* parent = …) const.

C++ documentation:

Creates a new QTextDocument that is a copy of this text document. parent is the parent of the returned text document.

pub unsafe fn clone_0a(&self) -> MutPtr<QTextDocument>[src]

Creates a new QTextDocument that is a copy of this text document. parent is the parent of the returned text document.

Calls C++ function: QTextDocument* QTextDocument::clone() const.

C++ documentation:

Creates a new QTextDocument that is a copy of this text document. parent is the parent of the returned text document.

pub unsafe fn default_cursor_move_style(&self) -> CursorMoveStyle[src]

The default cursor movement style is used by all QTextCursor objects created from the document. The default is Qt::LogicalMoveStyle.

Calls C++ function: Qt::CursorMoveStyle QTextDocument::defaultCursorMoveStyle() const.

C++ documentation:

The default cursor movement style is used by all QTextCursor objects created from the document. The default is Qt::LogicalMoveStyle.

This function was introduced in Qt 4.8.

See also setDefaultCursorMoveStyle().

pub unsafe fn default_font(&self) -> CppBox<QFont>[src]

This property holds the default font used to display the document's text

Calls C++ function: QFont QTextDocument::defaultFont() const.

C++ documentation:

This property holds the default font used to display the document's text

Access functions:

QFont defaultFont() const
void setDefaultFont(const QFont &font)

pub unsafe fn default_style_sheet(&self) -> CppBox<QString>[src]

The default style sheet is applied to all newly HTML formatted text that is inserted into the document, for example using setHtml() or QTextCursor::insertHtml().

Calls C++ function: QString QTextDocument::defaultStyleSheet() const.

C++ documentation:

The default style sheet is applied to all newly HTML formatted text that is inserted into the document, for example using setHtml() or QTextCursor::insertHtml().

The style sheet needs to be compliant to CSS 2.1 syntax.

Note: Changing the default style sheet does not have any effect to the existing content of the document.

This property was introduced in Qt 4.2.

Access functions:

QString defaultStyleSheet() const
void setDefaultStyleSheet(const QString &sheet)

See also Supported HTML Subset.

pub unsafe fn default_text_option(&self) -> CppBox<QTextOption>[src]

This property holds the default text option will be set on all QTextLayouts in the document.

Calls C++ function: QTextOption QTextDocument::defaultTextOption() const.

C++ documentation:

This property holds the default text option will be set on all QTextLayouts in the document.

When QTextBlocks are created, the defaultTextOption is set on their QTextLayout. This allows setting global properties for the document such as the default word wrap mode.

Access functions:

QTextOption defaultTextOption() const
void setDefaultTextOption(const QTextOption &option)

pub unsafe fn document_layout(&self) -> MutPtr<QAbstractTextDocumentLayout>[src]

Returns the document layout for this document.

Calls C++ function: QAbstractTextDocumentLayout* QTextDocument::documentLayout() const.

C++ documentation:

Returns the document layout for this document.

See also setDocumentLayout().

pub unsafe fn document_margin(&self) -> c_double[src]

The margin around the document. The default is 4.

Calls C++ function: double QTextDocument::documentMargin() const.

C++ documentation:

The margin around the document. The default is 4.

This property was introduced in Qt 4.5.

Access functions:

qreal documentMargin() const
void setDocumentMargin(qreal margin)

pub unsafe fn draw_contents_2a(
    &mut self,
    painter: impl CastInto<MutPtr<QPainter>>,
    rect: impl CastInto<Ref<QRectF>>
)
[src]

Draws the content of the document with painter p, clipped to rect. If rect is a null rectangle (default) then the document is painted unclipped.

Calls C++ function: void QTextDocument::drawContents(QPainter* painter, const QRectF& rect = …).

C++ documentation:

Draws the content of the document with painter p, clipped to rect. If rect is a null rectangle (default) then the document is painted unclipped.

This function was introduced in Qt 4.2.

pub unsafe fn draw_contents_1a(
    &mut self,
    painter: impl CastInto<MutPtr<QPainter>>
)
[src]

Draws the content of the document with painter p, clipped to rect. If rect is a null rectangle (default) then the document is painted unclipped.

Calls C++ function: void QTextDocument::drawContents(QPainter* painter).

C++ documentation:

Draws the content of the document with painter p, clipped to rect. If rect is a null rectangle (default) then the document is painted unclipped.

This function was introduced in Qt 4.2.

pub unsafe fn end(&self) -> CppBox<QTextBlock>[src]

This function returns a block to test for the end of the document while iterating over it.

Calls C++ function: QTextBlock QTextDocument::end() const.

C++ documentation:

This function returns a block to test for the end of the document while iterating over it.


      for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next())
          cout << it.text().toStdString() << endl;

The block returned is invalid and represents the block after the last block in the document. You can use lastBlock() to retrieve the last valid block of the document.

See also lastBlock().

pub unsafe fn find_q_string_int_q_flags_find_flag(
    &self,
    sub_string: impl CastInto<Ref<QString>>,
    from: c_int,
    options: QFlags<FindFlag>
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QString& subString, int from = …, QFlags<QTextDocument::FindFlag> options = …) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence of the string, subString, in the document. The search starts at the given position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if subString was found; otherwise returns a null cursor.

If the position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

pub unsafe fn find_q_string_q_text_cursor_q_flags_find_flag(
    &self,
    sub_string: impl CastInto<Ref<QString>>,
    cursor: impl CastInto<Ref<QTextCursor>>,
    options: QFlags<FindFlag>
) -> CppBox<QTextCursor>
[src]

Finds the next occurrence of the string, subString, in the document. The search starts at the position of the given cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Calls C++ function: QTextCursor QTextDocument::find(const QString& subString, const QTextCursor& cursor, QFlags<QTextDocument::FindFlag> options = …) const.

C++ documentation:

Finds the next occurrence of the string, subString, in the document. The search starts at the position of the given cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if subString was found; otherwise returns a null cursor.

If the given cursor has a selection, the search begins after the selection; otherwise it begins at the cursor's position.

By default the search is case-sensitive, and can match text anywhere in the document.

pub unsafe fn find_q_reg_exp_int_q_flags_find_flag(
    &self,
    expr: impl CastInto<Ref<QRegExp>>,
    from: c_int,
    options: QFlags<FindFlag>
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QRegExp& expr, int from = …, QFlags<QTextDocument::FindFlag> options = …) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the given from position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed. The FindCaseSensitively option is ignored for this overload, use QRegExp::caseSensitivity instead.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the from position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

pub unsafe fn find_q_reg_exp_q_text_cursor_q_flags_find_flag(
    &self,
    expr: impl CastInto<Ref<QRegExp>>,
    cursor: impl CastInto<Ref<QTextCursor>>,
    options: QFlags<FindFlag>
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QRegExp& expr, const QTextCursor& cursor, QFlags<QTextDocument::FindFlag> options = …) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the position of the given from cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed. The FindCaseSensitively option is ignored for this overload, use QRegExp::caseSensitivity instead.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the given cursor has a selection, the search begins after the selection; otherwise it begins at the cursor's position.

By default the search is case-sensitive, and can match text anywhere in the document.

pub unsafe fn find_q_regular_expression_int_q_flags_find_flag(
    &self,
    expr: impl CastInto<Ref<QRegularExpression>>,
    from: c_int,
    options: QFlags<FindFlag>
) -> CppBox<QTextCursor>
[src]

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

Calls C++ function: QTextCursor QTextDocument::find(const QRegularExpression& expr, int from = …, QFlags<QTextDocument::FindFlag> options = …) const.

C++ documentation:

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the given from position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the from position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

This function was introduced in Qt 5.5.

pub unsafe fn find_q_regular_expression_q_text_cursor_q_flags_find_flag(
    &self,
    expr: impl CastInto<Ref<QRegularExpression>>,
    cursor: impl CastInto<Ref<QTextCursor>>,
    options: QFlags<FindFlag>
) -> CppBox<QTextCursor>
[src]

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

Calls C++ function: QTextCursor QTextDocument::find(const QRegularExpression& expr, const QTextCursor& cursor, QFlags<QTextDocument::FindFlag> options = …) const.

C++ documentation:

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the position of the given cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the given cursor has a selection, the search begins after the selection; otherwise it begins at the cursor's position.

By default the search is case-sensitive, and can match text anywhere in the document.

This function was introduced in Qt 5.5.

pub unsafe fn find_q_string_int(
    &self,
    sub_string: impl CastInto<Ref<QString>>,
    from: c_int
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QString& subString, int from = …) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence of the string, subString, in the document. The search starts at the given position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if subString was found; otherwise returns a null cursor.

If the position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

pub unsafe fn find_q_string(
    &self,
    sub_string: impl CastInto<Ref<QString>>
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QString& subString) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence of the string, subString, in the document. The search starts at the given position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if subString was found; otherwise returns a null cursor.

If the position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

pub unsafe fn find_q_string_q_text_cursor(
    &self,
    sub_string: impl CastInto<Ref<QString>>,
    cursor: impl CastInto<Ref<QTextCursor>>
) -> CppBox<QTextCursor>
[src]

Finds the next occurrence of the string, subString, in the document. The search starts at the position of the given cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Calls C++ function: QTextCursor QTextDocument::find(const QString& subString, const QTextCursor& cursor) const.

C++ documentation:

Finds the next occurrence of the string, subString, in the document. The search starts at the position of the given cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if subString was found; otherwise returns a null cursor.

If the given cursor has a selection, the search begins after the selection; otherwise it begins at the cursor's position.

By default the search is case-sensitive, and can match text anywhere in the document.

pub unsafe fn find_q_reg_exp_int(
    &self,
    expr: impl CastInto<Ref<QRegExp>>,
    from: c_int
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QRegExp& expr, int from = …) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the given from position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed. The FindCaseSensitively option is ignored for this overload, use QRegExp::caseSensitivity instead.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the from position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

pub unsafe fn find_q_reg_exp(
    &self,
    expr: impl CastInto<Ref<QRegExp>>
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QRegExp& expr) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the given from position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed. The FindCaseSensitively option is ignored for this overload, use QRegExp::caseSensitivity instead.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the from position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

pub unsafe fn find_q_reg_exp_q_text_cursor(
    &self,
    expr: impl CastInto<Ref<QRegExp>>,
    cursor: impl CastInto<Ref<QTextCursor>>
) -> CppBox<QTextCursor>
[src]

This is an overloaded function.

Calls C++ function: QTextCursor QTextDocument::find(const QRegExp& expr, const QTextCursor& cursor) const.

C++ documentation:

This is an overloaded function.

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the position of the given from cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed. The FindCaseSensitively option is ignored for this overload, use QRegExp::caseSensitivity instead.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the given cursor has a selection, the search begins after the selection; otherwise it begins at the cursor's position.

By default the search is case-sensitive, and can match text anywhere in the document.

pub unsafe fn find_q_regular_expression_int(
    &self,
    expr: impl CastInto<Ref<QRegularExpression>>,
    from: c_int
) -> CppBox<QTextCursor>
[src]

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

Calls C++ function: QTextCursor QTextDocument::find(const QRegularExpression& expr, int from = …) const.

C++ documentation:

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the given from position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the from position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

This function was introduced in Qt 5.5.

pub unsafe fn find_q_regular_expression(
    &self,
    expr: impl CastInto<Ref<QRegularExpression>>
) -> CppBox<QTextCursor>
[src]

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

Calls C++ function: QTextCursor QTextDocument::find(const QRegularExpression& expr) const.

C++ documentation:

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the given from position, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the from position is 0 (the default) the search begins from the beginning of the document; otherwise it begins at the specified position.

This function was introduced in Qt 5.5.

pub unsafe fn find_q_regular_expression_q_text_cursor(
    &self,
    expr: impl CastInto<Ref<QRegularExpression>>,
    cursor: impl CastInto<Ref<QTextCursor>>
) -> CppBox<QTextCursor>
[src]

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

Calls C++ function: QTextCursor QTextDocument::find(const QRegularExpression& expr, const QTextCursor& cursor) const.

C++ documentation:

Finds the next occurrence that matches the given regular expression, expr, within the same paragraph in the document.

The search starts at the position of the given cursor, and proceeds forwards through the document unless specified otherwise in the search options. The options control the type of search performed.

Returns a cursor with the match selected if a match was found; otherwise returns a null cursor.

If the given cursor has a selection, the search begins after the selection; otherwise it begins at the cursor's position.

By default the search is case-sensitive, and can match text anywhere in the document.

This function was introduced in Qt 5.5.

pub unsafe fn find_block(&self, pos: c_int) -> CppBox<QTextBlock>[src]

Returns the text block that contains the pos-th character.

Calls C++ function: QTextBlock QTextDocument::findBlock(int pos) const.

C++ documentation:

Returns the text block that contains the pos-th character.

pub unsafe fn find_block_by_line_number(
    &self,
    block_number: c_int
) -> CppBox<QTextBlock>
[src]

Returns the text block that contains the specified lineNumber.

Calls C++ function: QTextBlock QTextDocument::findBlockByLineNumber(int blockNumber) const.

C++ documentation:

Returns the text block that contains the specified lineNumber.

This function was introduced in Qt 4.5.

See also QTextBlock::firstLineNumber().

pub unsafe fn find_block_by_number(
    &self,
    block_number: c_int
) -> CppBox<QTextBlock>
[src]

Returns the text block with the specified blockNumber.

Calls C++ function: QTextBlock QTextDocument::findBlockByNumber(int blockNumber) const.

C++ documentation:

Returns the text block with the specified blockNumber.

This function was introduced in Qt 4.4.

See also QTextBlock::blockNumber().

pub unsafe fn first_block(&self) -> CppBox<QTextBlock>[src]

Returns the document's first text block.

Calls C++ function: QTextBlock QTextDocument::firstBlock() const.

C++ documentation:

Returns the document's first text block.

This function was introduced in Qt 4.4.

pub unsafe fn frame_at(&self, pos: c_int) -> MutPtr<QTextFrame>[src]

Calls C++ function: QTextFrame* QTextDocument::frameAt(int pos) const.

pub unsafe fn ideal_width(&self) -> c_double[src]

Returns the ideal width of the text document. The ideal width is the actually used width of the document without optional alignments taken into account. It is always <= size().width().

Calls C++ function: double QTextDocument::idealWidth() const.

C++ documentation:

Returns the ideal width of the text document. The ideal width is the actually used width of the document without optional alignments taken into account. It is always <= size().width().

This function was introduced in Qt 4.2.

See also adjustSize() and textWidth.

pub unsafe fn indent_width(&self) -> c_double[src]

Returns the width used for text list and text block indenting.

Calls C++ function: double QTextDocument::indentWidth() const.

C++ documentation:

Returns the width used for text list and text block indenting.

The indent properties of QTextListFormat and QTextBlockFormat specify multiples of this value. The default indent width is 40.

This property was introduced in Qt 4.4.

Access functions:

qreal indentWidth() const
void setIndentWidth(qreal width)

pub unsafe fn is_empty(&self) -> bool[src]

Returns true if the document is empty; otherwise returns false.

Calls C++ function: bool QTextDocument::isEmpty() const.

C++ documentation:

Returns true if the document is empty; otherwise returns false.

pub unsafe fn is_modified(&self) -> bool[src]

This property holds whether the document has been modified by the user

Calls C++ function: bool QTextDocument::isModified() const.

C++ documentation:

This property holds whether the document has been modified by the user

By default, this property is false.

Access functions:

bool isModified() const
void setModified(bool m = true)

See also modificationChanged().

pub unsafe fn is_redo_available(&self) -> bool[src]

Returns true if redo is available; otherwise returns false.

Calls C++ function: bool QTextDocument::isRedoAvailable() const.

C++ documentation:

Returns true if redo is available; otherwise returns false.

See also isUndoAvailable() and availableRedoSteps().

pub unsafe fn is_undo_available(&self) -> bool[src]

Returns true if undo is available; otherwise returns false.

Calls C++ function: bool QTextDocument::isUndoAvailable() const.

C++ documentation:

Returns true if undo is available; otherwise returns false.

See also isRedoAvailable() and availableUndoSteps().

pub unsafe fn is_undo_redo_enabled(&self) -> bool[src]

This property holds whether undo/redo are enabled for this document

Calls C++ function: bool QTextDocument::isUndoRedoEnabled() const.

C++ documentation:

This property holds whether undo/redo are enabled for this document

This defaults to true. If disabled, the undo stack is cleared and no items will be added to it.

Access functions:

bool isUndoRedoEnabled() const
void setUndoRedoEnabled(bool enable)

pub unsafe fn last_block(&self) -> CppBox<QTextBlock>[src]

Returns the document's last (valid) text block.

Calls C++ function: QTextBlock QTextDocument::lastBlock() const.

C++ documentation:

Returns the document's last (valid) text block.

This function was introduced in Qt 4.4.

pub unsafe fn line_count(&self) -> c_int[src]

Returns the number of lines of this document (if the layout supports this). Otherwise, this is identical to the number of blocks.

Calls C++ function: int QTextDocument::lineCount() const.

C++ documentation:

Returns the number of lines of this document (if the layout supports this). Otherwise, this is identical to the number of blocks.

This function was introduced in Qt 4.5.

See also blockCount() and characterCount().

pub unsafe fn mark_contents_dirty(&mut self, from: c_int, length: c_int)[src]

Marks the contents specified by the given position and length as "dirty", informing the document that it needs to be laid out again.

Calls C++ function: void QTextDocument::markContentsDirty(int from, int length).

C++ documentation:

Marks the contents specified by the given position and length as "dirty", informing the document that it needs to be laid out again.

pub unsafe fn maximum_block_count(&self) -> c_int[src]

Specifies the limit for blocks in the document.

Calls C++ function: int QTextDocument::maximumBlockCount() const.

C++ documentation:

Specifies the limit for blocks in the document.

Specifies the maximum number of blocks the document may have. If there are more blocks in the document that specified with this property blocks are removed from the beginning of the document.

A negative or zero value specifies that the document may contain an unlimited amount of blocks.

The default value is 0.

Note that setting this property will apply the limit immediately to the document contents.

Setting this property also disables the undo redo history.

This property is undefined in documents with tables or frames.

This property was introduced in Qt 4.2.

Access functions:

int maximumBlockCount() const
void setMaximumBlockCount(int maximum)

pub unsafe fn meta_information(&self, info: MetaInformation) -> CppBox<QString>[src]

Returns meta information about the document of the type specified by info.

Calls C++ function: QString QTextDocument::metaInformation(QTextDocument::MetaInformation info) const.

C++ documentation:

Returns meta information about the document of the type specified by info.

See also setMetaInformation().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QTextDocument::metaObject() const.

pub unsafe fn from_q_object(
    parent: impl CastInto<MutPtr<QObject>>
) -> CppBox<QTextDocument>
[src]

Constructs an empty QTextDocument with the given parent.

Calls C++ function: [constructor] void QTextDocument::QTextDocument(QObject* parent = …).

C++ documentation:

Constructs an empty QTextDocument with the given parent.

pub unsafe fn from_q_string_q_object(
    text: impl CastInto<Ref<QString>>,
    parent: impl CastInto<MutPtr<QObject>>
) -> CppBox<QTextDocument>
[src]

Constructs a QTextDocument containing the plain (unformatted) text specified, and with the given parent.

Calls C++ function: [constructor] void QTextDocument::QTextDocument(const QString& text, QObject* parent = …).

C++ documentation:

Constructs a QTextDocument containing the plain (unformatted) text specified, and with the given parent.

pub unsafe fn new() -> CppBox<QTextDocument>[src]

The QTextDocument class holds formatted text.

Calls C++ function: [constructor] void QTextDocument::QTextDocument().

C++ documentation:

The QTextDocument class holds formatted text.

QTextDocument is a container for structured rich text documents, providing support for styled text and various types of document elements, such as lists, tables, frames, and images. They can be created for use in a QTextEdit, or used independently.

Each document element is described by an associated format object. Each format object is treated as a unique object by QTextDocuments, and can be passed to objectForFormat() to obtain the document element that it is applied to.

A QTextDocument can be edited programmatically using a QTextCursor, and its contents can be examined by traversing the document structure. The entire document structure is stored as a hierarchy of document elements beneath the root frame, found with the rootFrame() function. Alternatively, if you just want to iterate over the textual contents of the document you can use begin(), end(), and findBlock() to retrieve text blocks that you can examine and iterate over.

The layout of a document is determined by the documentLayout(); you can create your own QAbstractTextDocumentLayout subclass and set it using setDocumentLayout() if you want to use your own layout logic. The document's title and other meta-information can be obtained by calling the metaInformation() function. For documents that are exposed to users through the QTextEdit class, the document title is also available via the QTextEdit::documentTitle() function.

The toPlainText() and toHtml() convenience functions allow you to retrieve the contents of the document as plain text and HTML. The document's text can be searched using the find() functions.

Undo/redo of operations performed on the document can be controlled using the setUndoRedoEnabled() function. The undo/redo system can be controlled by an editor widget through the undo() and redo() slots; the document also provides contentsChanged(), undoAvailable(), and redoAvailable() signals that inform connected editor widgets about the state of the undo/redo system. The following are the undo/redo operations of a QTextDocument:

  • Insertion or removal of characters. A sequence of insertions or removals within the same text block are regarded as a single undo/redo operation.
  • Insertion or removal of text blocks. Sequences of insertion or removals in a single operation (e.g., by selecting and then deleting text) are regarded as a single undo/redo operation.
  • Text character format changes.
  • Text block format changes.
  • Text block group format changes.

pub unsafe fn from_q_string(
    text: impl CastInto<Ref<QString>>
) -> CppBox<QTextDocument>
[src]

Constructs a QTextDocument containing the plain (unformatted) text specified, and with the given parent.

Calls C++ function: [constructor] void QTextDocument::QTextDocument(const QString& text).

C++ documentation:

Constructs a QTextDocument containing the plain (unformatted) text specified, and with the given parent.

pub unsafe fn object(&self, object_index: c_int) -> MutPtr<QTextObject>[src]

Returns the text object associated with the given objectIndex.

Calls C++ function: QTextObject* QTextDocument::object(int objectIndex) const.

C++ documentation:

Returns the text object associated with the given objectIndex.

pub unsafe fn object_for_format(
    &self,
    arg1: impl CastInto<Ref<QTextFormat>>
) -> MutPtr<QTextObject>
[src]

Returns the text object associated with the format f.

Calls C++ function: QTextObject* QTextDocument::objectForFormat(const QTextFormat& arg1) const.

C++ documentation:

Returns the text object associated with the format f.

pub unsafe fn page_count(&self) -> c_int[src]

returns the number of pages in this document.

Calls C++ function: int QTextDocument::pageCount() const.

C++ documentation:

returns the number of pages in this document.

pub unsafe fn page_size(&self) -> CppBox<QSizeF>[src]

This property holds the page size that should be used for laying out the document

Calls C++ function: QSizeF QTextDocument::pageSize() const.

C++ documentation:

This property holds the page size that should be used for laying out the document

The units are determined by the underlying paint device. The size is measured in logical pixels when painting to the screen, and in points (1/72 inch) when painting to a printer.

By default, for a newly-created, empty document, this property contains an undefined size.

Access functions:

QSizeF pageSize() const
void setPageSize(const QSizeF &size)

See also modificationChanged().

pub unsafe fn print(&self, printer: impl CastInto<MutPtr<QPagedPaintDevice>>)[src]

Prints the document to the given printer. The QPageablePaintDevice must be set up before being used with this function.

Calls C++ function: void QTextDocument::print(QPagedPaintDevice* printer) const.

C++ documentation:

Prints the document to the given printer. The QPageablePaintDevice must be set up before being used with this function.

This is only a convenience method to print the whole document to the printer.

If the document is already paginated through a specified height in the pageSize() property it is printed as-is.

If the document is not paginated, like for example a document used in a QTextEdit, then a temporary copy of the document is created and the copy is broken into multiple pages according to the size of the paint device's paperRect(). By default a 2 cm margin is set around the document contents. In addition the current page number is printed at the bottom of each page.

See also QTextEdit::print().

pub unsafe fn qt_metacall(
    &mut self,
    arg1: Call,
    arg2: c_int,
    arg3: impl CastInto<MutPtr<*mut c_void>>
) -> c_int
[src]

Calls C++ function: virtual int QTextDocument::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(
    &mut self,
    arg1: impl CastInto<Ptr<c_char>>
) -> MutPtr<c_void>
[src]

Calls C++ function: virtual void* QTextDocument::qt_metacast(const char* arg1).

pub unsafe fn redo_1a(&mut self, cursor: impl CastInto<MutPtr<QTextCursor>>)[src]

Redoes the last editing operation on the document if redo is available.

Calls C++ function: void QTextDocument::redo(QTextCursor* cursor).

C++ documentation:

Redoes the last editing operation on the document if redo is available.

The provided cursor is positioned at the end of the location where the edition operation was redone.

This function was introduced in Qt 4.2.

pub unsafe fn redo_0a(&mut self)[src]

This is an overloaded function.

Calls C++ function: [slot] void QTextDocument::redo().

C++ documentation:

This is an overloaded function.

Redoes the last editing operation on the document if redo is available.

pub unsafe fn resource(
    &self,
    type_: c_int,
    name: impl CastInto<Ref<QUrl>>
) -> CppBox<QVariant>
[src]

Returns data of the specified type from the resource with the given name.

Calls C++ function: QVariant QTextDocument::resource(int type, const QUrl& name) const.

C++ documentation:

Returns data of the specified type from the resource with the given name.

This function is called by the rich text engine to request data that isn't directly stored by QTextDocument, but still associated with it. For example, images are referenced indirectly by the name attribute of a QTextImageFormat object.

Resources are cached internally in the document. If a resource can not be found in the cache, loadResource is called to try to load the resource. loadResource should then use addResource to add the resource to the cache.

See also QTextDocument::ResourceType.

pub unsafe fn revision(&self) -> c_int[src]

Returns the document's revision (if undo is enabled).

Calls C++ function: int QTextDocument::revision() const.

C++ documentation:

Returns the document's revision (if undo is enabled).

The revision is guaranteed to increase when a document that is not modified is edited.

This function was introduced in Qt 4.4.

See also QTextBlock::revision() and isModified().

pub unsafe fn root_frame(&self) -> MutPtr<QTextFrame>[src]

Returns the document's root frame.

Calls C++ function: QTextFrame* QTextDocument::rootFrame() const.

C++ documentation:

Returns the document's root frame.

pub unsafe fn set_base_url(&mut self, url: impl CastInto<Ref<QUrl>>)[src]

This property holds the base URL used to resolve relative resource URLs within the document.

Calls C++ function: void QTextDocument::setBaseUrl(const QUrl& url).

C++ documentation:

This property holds the base URL used to resolve relative resource URLs within the document.

Resource URLs are resolved to be within the same directory as the target of the base URL meaning any portion of the path after the last '/' will be ignored.

Base URLRelative URLResolved URL
file:///path/to/contentimages/logo.pngfile:///path/to/images/logo.png
file:///path/to/content/images/logo.pngfile:///path/to/content/images/logo.png
file:///path/to/content/index.htmlimages/logo.pngfile:///path/to/content/images/logo.png
file:///path/to/content/images/../images/logo.pngfile:///path/to/content/images/logo.png

This property was introduced in Qt 5.3.

Access functions:

QUrl baseUrl() const
void setBaseUrl(const QUrl &url)

Notifier signal:

void baseUrlChanged(const QUrl &url)

pub unsafe fn set_default_cursor_move_style(&mut self, style: CursorMoveStyle)[src]

Sets the default cursor movement style to the given style.

Calls C++ function: void QTextDocument::setDefaultCursorMoveStyle(Qt::CursorMoveStyle style).

C++ documentation:

Sets the default cursor movement style to the given style.

This function was introduced in Qt 4.8.

See also defaultCursorMoveStyle().

pub unsafe fn set_default_font(&mut self, font: impl CastInto<Ref<QFont>>)[src]

Sets the default font to use in the document layout.

Calls C++ function: void QTextDocument::setDefaultFont(const QFont& font).

C++ documentation:

Sets the default font to use in the document layout.

Note: Setter function for property defaultFont.

See also defaultFont().

pub unsafe fn set_default_style_sheet(
    &mut self,
    sheet: impl CastInto<Ref<QString>>
)
[src]

The default style sheet is applied to all newly HTML formatted text that is inserted into the document, for example using setHtml() or QTextCursor::insertHtml().

Calls C++ function: void QTextDocument::setDefaultStyleSheet(const QString& sheet).

C++ documentation:

The default style sheet is applied to all newly HTML formatted text that is inserted into the document, for example using setHtml() or QTextCursor::insertHtml().

The style sheet needs to be compliant to CSS 2.1 syntax.

Note: Changing the default style sheet does not have any effect to the existing content of the document.

This property was introduced in Qt 4.2.

Access functions:

QString defaultStyleSheet() const
void setDefaultStyleSheet(const QString &sheet)

See also Supported HTML Subset.

pub unsafe fn set_default_text_option(
    &mut self,
    option: impl CastInto<Ref<QTextOption>>
)
[src]

Sets the default text option to option.

Calls C++ function: void QTextDocument::setDefaultTextOption(const QTextOption& option).

C++ documentation:

Sets the default text option to option.

This function was introduced in Qt 4.3.

Note: Setter function for property defaultTextOption.

See also defaultTextOption().

pub unsafe fn set_document_layout(
    &mut self,
    layout: impl CastInto<MutPtr<QAbstractTextDocumentLayout>>
)
[src]

Sets the document to use the given layout. The previous layout is deleted.

Calls C++ function: void QTextDocument::setDocumentLayout(QAbstractTextDocumentLayout* layout).

C++ documentation:

Sets the document to use the given layout. The previous layout is deleted.

See also documentLayoutChanged().

pub unsafe fn set_document_margin(&mut self, margin: c_double)[src]

The margin around the document. The default is 4.

Calls C++ function: void QTextDocument::setDocumentMargin(double margin).

C++ documentation:

The margin around the document. The default is 4.

This property was introduced in Qt 4.5.

Access functions:

qreal documentMargin() const
void setDocumentMargin(qreal margin)

pub unsafe fn set_html(&mut self, html: impl CastInto<Ref<QString>>)[src]

Replaces the entire contents of the document with the given HTML-formatted text in the html string. The undo/redo history is reset when this function is called.

Calls C++ function: void QTextDocument::setHtml(const QString& html).

C++ documentation:

Replaces the entire contents of the document with the given HTML-formatted text in the html string. The undo/redo history is reset when this function is called.

The HTML formatting is respected as much as possible; for example, "<b>bold</b> text" will produce text where the first word has a font weight that gives it a bold appearance: "bold text".

Note: It is the responsibility of the caller to make sure that the text is correctly decoded when a QString containing HTML is created and passed to setHtml().

See also setPlainText() and Supported HTML Subset.

pub unsafe fn set_indent_width(&mut self, width: c_double)[src]

Sets the width used for text list and text block indenting.

Calls C++ function: void QTextDocument::setIndentWidth(double width).

C++ documentation:

Sets the width used for text list and text block indenting.

The indent properties of QTextListFormat and QTextBlockFormat specify multiples of this value. The default indent width is 40 .

This function was introduced in Qt 4.4.

Note: Setter function for property indentWidth.

See also indentWidth().

pub unsafe fn set_maximum_block_count(&mut self, maximum: c_int)[src]

Specifies the limit for blocks in the document.

Calls C++ function: void QTextDocument::setMaximumBlockCount(int maximum).

C++ documentation:

Specifies the limit for blocks in the document.

Specifies the maximum number of blocks the document may have. If there are more blocks in the document that specified with this property blocks are removed from the beginning of the document.

A negative or zero value specifies that the document may contain an unlimited amount of blocks.

The default value is 0.

Note that setting this property will apply the limit immediately to the document contents.

Setting this property also disables the undo redo history.

This property is undefined in documents with tables or frames.

This property was introduced in Qt 4.2.

Access functions:

int maximumBlockCount() const
void setMaximumBlockCount(int maximum)

pub unsafe fn set_meta_information(
    &mut self,
    info: MetaInformation,
    arg2: impl CastInto<Ref<QString>>
)
[src]

Sets the document's meta information of the type specified by info to the given string.

Calls C++ function: void QTextDocument::setMetaInformation(QTextDocument::MetaInformation info, const QString& arg2).

C++ documentation:

Sets the document's meta information of the type specified by info to the given string.

See also metaInformation().

pub unsafe fn set_modified_1a(&mut self, m: bool)[src]

This property holds whether the document has been modified by the user

Calls C++ function: [slot] void QTextDocument::setModified(bool m = …).

C++ documentation:

This property holds whether the document has been modified by the user

By default, this property is false.

Access functions:

bool isModified() const
void setModified(bool m = true)

See also modificationChanged().

pub unsafe fn set_modified_0a(&mut self)[src]

This property holds whether the document has been modified by the user

Calls C++ function: [slot] void QTextDocument::setModified().

C++ documentation:

This property holds whether the document has been modified by the user

By default, this property is false.

Access functions:

bool isModified() const
void setModified(bool m = true)

See also modificationChanged().

pub unsafe fn set_page_size(&mut self, size: impl CastInto<Ref<QSizeF>>)[src]

This property holds the page size that should be used for laying out the document

Calls C++ function: void QTextDocument::setPageSize(const QSizeF& size).

C++ documentation:

This property holds the page size that should be used for laying out the document

The units are determined by the underlying paint device. The size is measured in logical pixels when painting to the screen, and in points (1/72 inch) when painting to a printer.

By default, for a newly-created, empty document, this property contains an undefined size.

Access functions:

QSizeF pageSize() const
void setPageSize(const QSizeF &size)

See also modificationChanged().

pub unsafe fn set_plain_text(&mut self, text: impl CastInto<Ref<QString>>)[src]

Replaces the entire contents of the document with the given plain text. The undo/redo history is reset when this function is called.

Calls C++ function: void QTextDocument::setPlainText(const QString& text).

C++ documentation:

Replaces the entire contents of the document with the given plain text. The undo/redo history is reset when this function is called.

See also setHtml().

pub unsafe fn set_text_width(&mut self, width: c_double)[src]

The text width specifies the preferred width for text in the document. If the text (or content in general) is wider than the specified with it is broken into multiple lines and grows vertically. If the text cannot be broken into multiple lines to fit into the specified text width it will be larger and the size() and the idealWidth() property will reflect that.

Calls C++ function: void QTextDocument::setTextWidth(double width).

C++ documentation:

The text width specifies the preferred width for text in the document. If the text (or content in general) is wider than the specified with it is broken into multiple lines and grows vertically. If the text cannot be broken into multiple lines to fit into the specified text width it will be larger and the size() and the idealWidth() property will reflect that.

If the text width is set to -1 then the text will not be broken into multiple lines unless it is enforced through an explicit line break or a new paragraph.

The default value is -1.

Setting the text width will also set the page height to -1, causing the document to grow or shrink vertically in a continuous way. If you want the document layout to break the text into multiple pages then you have to set the pageSize property instead.

This property was introduced in Qt 4.2.

Access functions:

qreal textWidth() const
void setTextWidth(qreal width)

See also size(), idealWidth(), and pageSize().

pub unsafe fn set_undo_redo_enabled(&mut self, enable: bool)[src]

This property holds whether undo/redo are enabled for this document

Calls C++ function: void QTextDocument::setUndoRedoEnabled(bool enable).

C++ documentation:

This property holds whether undo/redo are enabled for this document

This defaults to true. If disabled, the undo stack is cleared and no items will be added to it.

Access functions:

bool isUndoRedoEnabled() const
void setUndoRedoEnabled(bool enable)

pub unsafe fn set_use_design_metrics(&mut self, b: bool)[src]

This property holds whether the document uses design metrics of fonts to improve the accuracy of text layout

Calls C++ function: void QTextDocument::setUseDesignMetrics(bool b).

C++ documentation:

This property holds whether the document uses design metrics of fonts to improve the accuracy of text layout

If this property is set to true, the layout will use design metrics. Otherwise, the metrics of the paint device as set on QAbstractTextDocumentLayout::setPaintDevice() will be used.

Using design metrics makes a layout have a width that is no longer dependent on hinting and pixel-rounding. This means that WYSIWYG text layout becomes possible because the width scales much more linearly based on paintdevice metrics than it would otherwise.

By default, this property is false.

This property was introduced in Qt 4.1.

Access functions:

bool useDesignMetrics() const
void setUseDesignMetrics(bool b)

pub unsafe fn size(&self) -> CppBox<QSizeF>[src]

Returns the actual size of the document. This is equivalent to documentLayout()->documentSize();

Calls C++ function: QSizeF QTextDocument::size() const.

C++ documentation:

Returns the actual size of the document. This is equivalent to documentLayout()->documentSize();

The size of the document can be changed either by setting a text width or setting an entire page size.

Note that the width is always >= pageSize().width().

By default, for a newly-created, empty document, this property contains a configuration-dependent size.

This property was introduced in Qt 4.2.

Access functions:

QSizeF size() const

See also setTextWidth(), setPageSize(), and idealWidth().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn text_width(&self) -> c_double[src]

The text width specifies the preferred width for text in the document. If the text (or content in general) is wider than the specified with it is broken into multiple lines and grows vertically. If the text cannot be broken into multiple lines to fit into the specified text width it will be larger and the size() and the idealWidth() property will reflect that.

Calls C++ function: double QTextDocument::textWidth() const.

C++ documentation:

The text width specifies the preferred width for text in the document. If the text (or content in general) is wider than the specified with it is broken into multiple lines and grows vertically. If the text cannot be broken into multiple lines to fit into the specified text width it will be larger and the size() and the idealWidth() property will reflect that.

If the text width is set to -1 then the text will not be broken into multiple lines unless it is enforced through an explicit line break or a new paragraph.

The default value is -1.

Setting the text width will also set the page height to -1, causing the document to grow or shrink vertically in a continuous way. If you want the document layout to break the text into multiple pages then you have to set the pageSize property instead.

This property was introduced in Qt 4.2.

Access functions:

qreal textWidth() const
void setTextWidth(qreal width)

See also size(), idealWidth(), and pageSize().

pub unsafe fn to_html_1a(
    &self,
    encoding: impl CastInto<Ref<QByteArray>>
) -> CppBox<QString>
[src]

Returns a string containing an HTML representation of the document.

Calls C++ function: QString QTextDocument::toHtml(const QByteArray& encoding = …) const.

C++ documentation:

Returns a string containing an HTML representation of the document.

The encoding parameter specifies the value for the charset attribute in the html header. For example if 'utf-8' is specified then the beginning of the generated html will look like this:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>...

If no encoding is specified then no such meta information is generated.

If you later on convert the returned html string into a byte array for transmission over a network or when saving to disk you should specify the encoding you're going to use for the conversion to a byte array here.

See also Supported HTML Subset.

pub unsafe fn to_html_0a(&self) -> CppBox<QString>[src]

Returns a string containing an HTML representation of the document.

Calls C++ function: QString QTextDocument::toHtml() const.

C++ documentation:

Returns a string containing an HTML representation of the document.

The encoding parameter specifies the value for the charset attribute in the html header. For example if 'utf-8' is specified then the beginning of the generated html will look like this:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>...

If no encoding is specified then no such meta information is generated.

If you later on convert the returned html string into a byte array for transmission over a network or when saving to disk you should specify the encoding you're going to use for the conversion to a byte array here.

See also Supported HTML Subset.

pub unsafe fn to_plain_text(&self) -> CppBox<QString>[src]

Returns the plain text contained in the document. If you want formatting information use a QTextCursor instead.

Calls C++ function: QString QTextDocument::toPlainText() const.

C++ documentation:

Returns the plain text contained in the document. If you want formatting information use a QTextCursor instead.

This function returns the same as toRawText(), but will replace some unicode characters with ASCII alternatives. In particular, no-break space (U+00A0) is replaced by a regular space (U+0020), and both paragraph (U+2029) and line (U+2028) separators are replaced by line feed (U+000A). If you need the precise contents of the document, use toRawText() instead.

Note: Embedded objects, such as images, are represented by a Unicode value U+FFFC (OBJECT REPLACEMENT CHARACTER).

See also toHtml().

pub unsafe fn to_raw_text(&self) -> CppBox<QString>[src]

Returns the raw text contained in the document without any formatting information. If you want formatting information use a QTextCursor instead.

Calls C++ function: QString QTextDocument::toRawText() const.

C++ documentation:

Returns the raw text contained in the document without any formatting information. If you want formatting information use a QTextCursor instead.

This function was introduced in Qt 5.9.

See also toPlainText().

pub unsafe fn tr(
    s: impl CastInto<Ptr<c_char>>,
    c: impl CastInto<Ptr<c_char>>,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QTextDocument::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: impl CastInto<Ptr<c_char>>,
    c: impl CastInto<Ptr<c_char>>,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QTextDocument::trUtf8(const char* s, const char* c, int n).

pub unsafe fn undo_1a(&mut self, cursor: impl CastInto<MutPtr<QTextCursor>>)[src]

Undoes the last editing operation on the document if undo is available. The provided cursor is positioned at the end of the location where the edition operation was undone.

Calls C++ function: void QTextDocument::undo(QTextCursor* cursor).

C++ documentation:

Undoes the last editing operation on the document if undo is available. The provided cursor is positioned at the end of the location where the edition operation was undone.

See the Qt Undo Framework documentation for details.

This function was introduced in Qt 4.2.

See also undoAvailable() and isUndoRedoEnabled().

pub unsafe fn undo_0a(&mut self)[src]

This is an overloaded function.

Calls C++ function: [slot] void QTextDocument::undo().

C++ documentation:

This is an overloaded function.

pub unsafe fn use_design_metrics(&self) -> bool[src]

This property holds whether the document uses design metrics of fonts to improve the accuracy of text layout

Calls C++ function: bool QTextDocument::useDesignMetrics() const.

C++ documentation:

This property holds whether the document uses design metrics of fonts to improve the accuracy of text layout

If this property is set to true, the layout will use design metrics. Otherwise, the metrics of the paint device as set on QAbstractTextDocumentLayout::setPaintDevice() will be used.

Using design metrics makes a layout have a width that is no longer dependent on hinting and pixel-rounding. This means that WYSIWYG text layout becomes possible because the width scales much more linearly based on paintdevice metrics than it would otherwise.

By default, this property is false.

This property was introduced in Qt 4.1.

Access functions:

bool useDesignMetrics() const
void setUseDesignMetrics(bool b)

Trait Implementations

impl Begin for QTextDocument[src]

type Output = CppBox<QTextBlock>

Output type.

unsafe fn begin(&self) -> CppBox<QTextBlock>[src]

Returns the document's first text block.

Calls C++ function: QTextBlock QTextDocument::begin() const.

C++ documentation:

Returns the document's first text block.

See also firstBlock().

impl CppDeletable for QTextDocument[src]

unsafe fn delete(&mut self)[src]

Destroys the document.

Calls C++ function: virtual [destructor] void QTextDocument::~QTextDocument().

C++ documentation:

Destroys the document.

impl Deref for QTextDocument[src]

type Target = QObject

The resulting type after dereferencing.

fn deref(&self) -> &QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QTextDocument* ptr).

impl DerefMut for QTextDocument[src]

fn deref_mut(&mut self) -> &mut QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QTextDocument* ptr).

impl DynamicCast<QTextDocument> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QTextDocument>[src]

Calls C++ function: QTextDocument* dynamic_cast<QTextDocument*>(QObject* ptr).

unsafe fn dynamic_cast_mut(ptr: MutPtr<QObject>) -> MutPtr<QTextDocument>[src]

Calls C++ function: QTextDocument* dynamic_cast<QTextDocument*>(QObject* ptr).

impl End for QTextDocument[src]

type Output = CppBox<QTextBlock>

Output type.

unsafe fn end(&self) -> CppBox<QTextBlock>[src]

This function returns a block to test for the end of the document while iterating over it.

Calls C++ function: QTextBlock QTextDocument::end() const.

C++ documentation:

This function returns a block to test for the end of the document while iterating over it.


      for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next())
          cout << it.text().toStdString() << endl;

The block returned is invalid and represents the block after the last block in the document. You can use lastBlock() to retrieve the last valid block of the document.

See also lastBlock().

impl Size for QTextDocument[src]

unsafe fn size(&self) -> usize[src]

Returns the actual size of the document. This is equivalent to documentLayout()->documentSize();

Calls C++ function: QSizeF QTextDocument::size() const.

C++ documentation:

Returns the actual size of the document. This is equivalent to documentLayout()->documentSize();

The size of the document can be changed either by setting a text width or setting an entire page size.

Note that the width is always >= pageSize().width().

By default, for a newly-created, empty document, this property contains a configuration-dependent size.

This property was introduced in Qt 4.2.

Access functions:

QSizeF size() const

See also setTextWidth(), setPageSize(), and idealWidth().

impl StaticDowncast<QTextDocument> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QTextDocument>[src]

Calls C++ function: QTextDocument* static_cast<QTextDocument*>(QObject* ptr).

unsafe fn static_downcast_mut(ptr: MutPtr<QObject>) -> MutPtr<QTextDocument>[src]

Calls C++ function: QTextDocument* static_cast<QTextDocument*>(QObject* ptr).

impl StaticUpcast<QObject> for QTextDocument[src]

unsafe fn static_upcast(ptr: Ptr<QTextDocument>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QTextDocument* ptr).

unsafe fn static_upcast_mut(ptr: MutPtr<QTextDocument>) -> MutPtr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QTextDocument* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.