Struct qt_gui::QTextDocument

source ·
#[repr(C)]
pub struct QTextDocument { /* private fields */ }
Expand description

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.

Implementations§

source§

impl QTextDocument

source

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

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().

source

pub fn contents_changed(&self) -> Signal<()>

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().

source

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

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().

source

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

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

source

pub fn undo_command_added(&self) -> Signal<()>

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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)
source

pub fn document_layout_changed(&self) -> Signal<()>

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().

source

pub fn slot_undo(&self) -> Receiver<()>

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.

source

pub fn slot_redo(&self) -> Receiver<()>

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.

source

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

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

source

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

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().

source

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

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" />”);

source

pub unsafe fn adjust_size(&self)

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.

source

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

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.

source

pub unsafe fn append_undo_item( &self, arg1: impl CastInto<Ptr<QAbstractUndoItem>> )

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

source

pub unsafe fn available_redo_steps(&self) -> c_int

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().

source

pub unsafe fn available_undo_steps(&self) -> c_int

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().

source

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

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)
source

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

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().

source

pub unsafe fn block_count(&self) -> c_int

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().

source

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

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().

source

pub unsafe fn character_count(&self) -> c_int

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().

source

pub unsafe fn clear(&self)

Clears the document.

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

C++ documentation:

Clears the document.

source

pub unsafe fn clear_undo_redo_stacks_1a(&self, history_to_clear: Stacks)

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().

source

pub unsafe fn clear_undo_redo_stacks_0a(&self)

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().

source

pub unsafe fn clone_1a( &self, parent: impl CastInto<Ptr<QObject>> ) -> QPtr<QTextDocument>

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.

source

pub unsafe fn clone_0a(&self) -> QPtr<QTextDocument>

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.

source

pub unsafe fn default_cursor_move_style(&self) -> CursorMoveStyle

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().

source

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

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)
source

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

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.

source

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

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)
source

pub unsafe fn document_layout(&self) -> QPtr<QAbstractTextDocumentLayout>

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().

source

pub unsafe fn document_margin(&self) -> c_double

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)
source

pub unsafe fn draw_contents_2a( &self, painter: impl CastInto<Ptr<QPainter>>, rect: impl CastInto<Ref<QRectF>> )

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.

source

pub unsafe fn draw_contents_1a(&self, painter: impl CastInto<Ptr<QPainter>>)

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.

source

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

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().

source

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>

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.

source

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>

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.

source

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>

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.

source

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>

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.

source

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>

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.

source

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>

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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.

source

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

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().

source

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

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().

source

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

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.

source

pub unsafe fn frame_at(&self, pos: c_int) -> QPtr<QTextFrame>

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

source

pub unsafe fn ideal_width(&self) -> c_double

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.

source

pub unsafe fn indent_width(&self) -> c_double

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)
source

pub unsafe fn is_empty(&self) -> bool

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.

source

pub unsafe fn is_modified(&self) -> bool

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().

source

pub unsafe fn is_redo_available(&self) -> bool

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().

source

pub unsafe fn is_undo_available(&self) -> bool

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().

source

pub unsafe fn is_undo_redo_enabled(&self) -> bool

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)
source

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

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.

source

pub unsafe fn line_count(&self) -> c_int

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().

source

pub unsafe fn mark_contents_dirty(&self, from: c_int, length: c_int)

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.

source

pub unsafe fn maximum_block_count(&self) -> c_int

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)
source

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

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().

source

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

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

source

pub unsafe fn from_q_object( parent: impl CastInto<Ptr<QObject>> ) -> QBox<QTextDocument>

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.

source

pub unsafe fn from_q_string_q_object( text: impl CastInto<Ref<QString>>, parent: impl CastInto<Ptr<QObject>> ) -> QBox<QTextDocument>

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.

source

pub unsafe fn new() -> QBox<QTextDocument>

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

pub unsafe fn from_q_string( text: impl CastInto<Ref<QString>> ) -> QBox<QTextDocument>

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.

source

pub unsafe fn object(&self, object_index: c_int) -> QPtr<QTextObject>

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.

source

pub unsafe fn object_for_format( &self, arg1: impl CastInto<Ref<QTextFormat>> ) -> QPtr<QTextObject>

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.

source

pub unsafe fn page_count(&self) -> c_int

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.

source

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

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().

source

pub unsafe fn print(&self, printer: impl CastInto<Ptr<QPagedPaintDevice>>)

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().

source

pub unsafe fn qt_metacall( &self, arg1: Call, arg2: c_int, arg3: *mut *mut c_void ) -> c_int

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

source

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void

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

source

pub unsafe fn redo_1a(&self, cursor: impl CastInto<Ptr<QTextCursor>>)

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.

source

pub unsafe fn redo_0a(&self)

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.

source

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

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.

source

pub unsafe fn revision(&self) -> c_int

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().

source

pub unsafe fn root_frame(&self) -> QPtr<QTextFrame>

Returns the document's root frame.

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

C++ documentation:

Returns the document’s root frame.

source

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

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)
source

pub unsafe fn set_default_cursor_move_style(&self, style: CursorMoveStyle)

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().

source

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

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().

source

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

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.

source

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

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().

source

pub unsafe fn set_document_layout( &self, layout: impl CastInto<Ptr<QAbstractTextDocumentLayout>> )

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().

source

pub unsafe fn set_document_margin(&self, margin: c_double)

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)
source

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

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.

source

pub unsafe fn set_indent_width(&self, width: c_double)

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().

source

pub unsafe fn set_markdown_2a( &self, markdown: impl CastInto<Ref<QString>>, features: QFlags<MarkdownFeature> )

Available on cpp_lib_version="5.14.0" only.

Replaces the entire contents of the document with the given Markdown-formatted text in the markdown string, with the given features supported. By default, all supported GitHub-style Markdown features are included; pass MarkdownDialectCommonMark for a more basic parse.

Calls C++ function: void QTextDocument::setMarkdown(const QString& markdown, QFlags<QTextDocument::MarkdownFeature> features = …).

C++ documentation:

Replaces the entire contents of the document with the given Markdown-formatted text in the markdown string, with the given features supported. By default, all supported GitHub-style Markdown features are included; pass MarkdownDialectCommonMark for a more basic parse.

The Markdown formatting is respected as much as possible; for example, "*bold* text" will produce text where the first word has a font weight that gives it an emphasized appearance.

Parsing of HTML included in the markdown string is handled in the same way as in setHtml; however, Markdown formatting inside HTML blocks is not supported.

Some features of the parser can be enabled or disabled via the features argument:

The default is MarkdownDialectGitHub.

The undo/redo history is reset when this function is called.

This function was introduced in Qt 5.14.

source

pub unsafe fn set_markdown_1a(&self, markdown: impl CastInto<Ref<QString>>)

Available on cpp_lib_version="5.14.0" only.

Replaces the entire contents of the document with the given Markdown-formatted text in the markdown string, with the given features supported. By default, all supported GitHub-style Markdown features are included; pass MarkdownDialectCommonMark for a more basic parse.

Calls C++ function: void QTextDocument::setMarkdown(const QString& markdown).

C++ documentation:

Replaces the entire contents of the document with the given Markdown-formatted text in the markdown string, with the given features supported. By default, all supported GitHub-style Markdown features are included; pass MarkdownDialectCommonMark for a more basic parse.

The Markdown formatting is respected as much as possible; for example, "*bold* text" will produce text where the first word has a font weight that gives it an emphasized appearance.

Parsing of HTML included in the markdown string is handled in the same way as in setHtml; however, Markdown formatting inside HTML blocks is not supported.

Some features of the parser can be enabled or disabled via the features argument:

The default is MarkdownDialectGitHub.

The undo/redo history is reset when this function is called.

This function was introduced in Qt 5.14.

source

pub unsafe fn set_maximum_block_count(&self, maximum: c_int)

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)
source

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

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().

source

pub unsafe fn set_modified_1a(&self, m: bool)

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().

source

pub unsafe fn set_modified_0a(&self)

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().

source

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

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().

source

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

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().

source

pub unsafe fn set_text_width(&self, width: c_double)

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().

source

pub unsafe fn set_undo_redo_enabled(&self, enable: bool)

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)
source

pub unsafe fn set_use_design_metrics(&self, b: bool)

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)
source

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

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().

source

pub unsafe fn static_meta_object() -> Ref<QMetaObject>

Returns a reference to the staticMetaObject field.

source

pub unsafe fn text_width(&self) -> c_double

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().

source

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

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.

source

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

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.

source

pub unsafe fn to_markdown_1a( &self, features: QFlags<MarkdownFeature> ) -> CppBox<QString>

Available on cpp_lib_version="5.14.0" only.

Returns a string containing a Markdown representation of the document with the given features, or an empty string if writing fails for any reason.

Calls C++ function: QString QTextDocument::toMarkdown(QFlags<QTextDocument::MarkdownFeature> features = …) const.

C++ documentation:

Returns a string containing a Markdown representation of the document with the given features, or an empty string if writing fails for any reason.

This function was introduced in Qt 5.14.

See also setMarkdown.

source

pub unsafe fn to_markdown_0a(&self) -> CppBox<QString>

Available on cpp_lib_version="5.14.0" only.

Returns a string containing a Markdown representation of the document with the given features, or an empty string if writing fails for any reason.

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

C++ documentation:

Returns a string containing a Markdown representation of the document with the given features, or an empty string if writing fails for any reason.

This function was introduced in Qt 5.14.

See also setMarkdown.

source

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

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().

source

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

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().

source

pub unsafe fn tr( s: *const c_char, c: *const c_char, n: c_int ) -> CppBox<QString>

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

source

pub unsafe fn tr_utf8( s: *const c_char, c: *const c_char, n: c_int ) -> CppBox<QString>

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

source

pub unsafe fn undo_1a(&self, cursor: impl CastInto<Ptr<QTextCursor>>)

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().

source

pub unsafe fn undo_0a(&self)

This is an overloaded function.

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

C++ documentation:

This is an overloaded function.

source

pub unsafe fn use_design_metrics(&self) -> bool

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)

Methods from Deref<Target = QObject>§

source

pub unsafe fn find_child<T>( &self, name: &str ) -> Result<QPtr<T>, FindChildError>

Finds a child of self with the specified object name and casts it to type T.

The search is performed recursively. If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned.

Returns an error if there is no child object with object name name or the found object cannot be cast to T.

source

pub fn destroyed(&self) -> Signal<(*mut QObject,)>

This signal is emitted immediately before the object obj is destroyed, and can not be blocked.

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

C++ documentation:

This signal is emitted immediately before the object obj is destroyed, and can not be blocked.

All the objects's children are destroyed immediately after this signal is emitted.

See also deleteLater() and QPointer.

source

pub fn object_name_changed(&self) -> Signal<(*const QString,)>

This signal is emitted after the object's name has been changed. The new object name is passed as objectName.

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

C++ documentation:

This signal is emitted after the object’s name has been changed. The new object name is passed as objectName.

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

Note: Notifier signal for property objectName.

See also QObject::objectName.

source

pub fn slot_delete_later(&self) -> Receiver<()>

Schedules this object for deletion.

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

C++ documentation:

Schedules this object for deletion.

The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.

Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.

Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.

See also destroyed() and QPointer.

source

pub unsafe fn block_signals(&self, b: bool) -> bool

If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.

Calls C++ function: bool QObject::blockSignals(bool b).

C++ documentation:

If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.

The return value is the previous value of signalsBlocked().

Note that the destroyed() signal will be emitted even if the signals for this object have been blocked.

Signals emitted while being blocked are not buffered.

See also signalsBlocked() and QSignalBlocker.

source

pub unsafe fn children(&self) -> Ref<QListOfQObject>

Returns a list of child objects. The QObjectList class is defined in the <QObject> header file as the following:

Calls C++ function: const QList<QObject*>& QObject::children() const.

C++ documentation:

Returns a list of child objects. The QObjectList class is defined in the <QObject> header file as the following:


  typedef QList<QObject*> QObjectList;

The first child added is the first object in the list and the last child added is the last object in the list, i.e. new children are appended at the end.

Note that the list order changes when QWidget children are raised or lowered. A widget that is raised becomes the last object in the list, and a widget that is lowered becomes the first object in the list.

See also findChild(), findChildren(), parent(), and setParent().

source

pub unsafe fn delete_later(&self)

Schedules this object for deletion.

Calls C++ function: [slot] void QObject::deleteLater().

C++ documentation:

Schedules this object for deletion.

The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g. deleteLater() is called on an object before QCoreApplication::exec()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.

Note that entering and leaving a new event loop (e.g., by opening a modal dialog) will not perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called.

Note: It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.

See also destroyed() and QPointer.

source

pub unsafe fn disconnect_char_q_object_char( &self, signal: *const i8, receiver: impl CastInto<Ptr<QObject>>, member: *const i8 ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const char* signal = …, const QObject* receiver = …, const char* member = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

source

pub unsafe fn disconnect_q_object_char( &self, receiver: impl CastInto<Ptr<QObject>>, member: *const i8 ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const QObject* receiver, const char* member = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects all signals in this object from receiver's method.

A signal-slot connection is removed when either of the objects involved are destroyed.

source

pub unsafe fn disconnect_char_q_object( &self, signal: *const i8, receiver: impl CastInto<Ptr<QObject>> ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const char* signal = …, const QObject* receiver = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

source

pub unsafe fn disconnect_char(&self, signal: *const i8) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const char* signal = …) const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

source

pub unsafe fn disconnect(&self) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect() const.

C++ documentation:

This function overloads disconnect().

Disconnects signal from method of receiver.

A signal-slot connection is removed when either of the objects involved are destroyed.

Note: This function is thread-safe.

source

pub unsafe fn disconnect_q_object( &self, receiver: impl CastInto<Ptr<QObject>> ) -> bool

This function overloads disconnect().

Calls C++ function: bool QObject::disconnect(const QObject* receiver) const.

C++ documentation:

This function overloads disconnect().

Disconnects all signals in this object from receiver's method.

A signal-slot connection is removed when either of the objects involved are destroyed.

source

pub unsafe fn dump_object_info_mut(&self)

Dumps information about signal connections, etc. for this object to the debug output.

Calls C++ function: void QObject::dumpObjectInfo().

C++ documentation:

Dumps information about signal connections, etc. for this object to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectTree().

source

pub unsafe fn dump_object_info(&self)

Dumps information about signal connections, etc. for this object to the debug output.

Calls C++ function: void QObject::dumpObjectInfo() const.

C++ documentation:

Dumps information about signal connections, etc. for this object to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectTree().

source

pub unsafe fn dump_object_tree_mut(&self)

Dumps a tree of children to the debug output.

Calls C++ function: void QObject::dumpObjectTree().

C++ documentation:

Dumps a tree of children to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectInfo().

source

pub unsafe fn dump_object_tree(&self)

Dumps a tree of children to the debug output.

Calls C++ function: void QObject::dumpObjectTree() const.

C++ documentation:

Dumps a tree of children to the debug output.

Note: before Qt 5.9, this function was not const.

See also dumpObjectInfo().

source

pub unsafe fn dynamic_property_names(&self) -> CppBox<QListOfQByteArray>

Returns the names of all properties that were dynamically added to the object using setProperty().

Calls C++ function: QList<QByteArray> QObject::dynamicPropertyNames() const.

C++ documentation:

Returns the names of all properties that were dynamically added to the object using setProperty().

This function was introduced in Qt 4.2.

source

pub unsafe fn eq(&self, p: impl CastInto<Ref<QPointerOfQObject>>) -> bool

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(QObject* o, const QPointer<QObject>& p).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

source

pub unsafe fn event(&self, event: impl CastInto<Ptr<QEvent>>) -> bool

This virtual function receives events to an object and should return true if the event e was recognized and processed.

Calls C++ function: virtual bool QObject::event(QEvent* event).

C++ documentation:

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

Make sure you call the parent event class implementation for all the events you did not handle.

Example:

class MyClass : public QWidget { Q_OBJECT

public: MyClass(QWidget *parent = 0); ~MyClass();

bool event(QEvent* ev) { if (ev->type() == QEvent::PolishRequest) { // overwrite handling of PolishRequest if any doThings(); return true; } else if (ev->type() == QEvent::Show) { // complement handling of Show if any doThings2(); QWidget::event(ev); return true; } // Make sure the rest of events are handled return QWidget::event(ev); } };

See also installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), and QCoreApplication::postEvent().

source

pub unsafe fn event_filter( &self, watched: impl CastInto<Ptr<QObject>>, event: impl CastInto<Ptr<QEvent>> ) -> bool

Filters events if this object has been installed as an event filter for the watched object.

Calls C++ function: virtual bool QObject::eventFilter(QObject* watched, QEvent* event).

C++ documentation:

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

class MainWindow : public QMainWindow { public: MainWindow();

protected: bool eventFilter(QObject obj, QEvent ev);

private: QTextEdit *textEdit; };

MainWindow::MainWindow() { textEdit = new QTextEdit; setCentralWidget(textEdit);

textEdit->installEventFilter(this); }

bool MainWindow::eventFilter(QObject obj, QEvent event) { if (obj == textEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent keyEvent = static_cast<QKeyEvent>(event); qDebug() << “Ate key press” << keyEvent->key(); return true; } else { return false; } } else { // pass the event on to the parent class return QMainWindow::eventFilter(obj, event); } }

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Warning: If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.

See also installEventFilter().

source

pub unsafe fn find_child_q_object_2a( &self, a_name: impl CastInto<Ref<QString>>, options: QFlags<FindChildOption> ) -> QPtr<QObject>

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QObject* QObject::findChild<QObject*>(const QString& aName = …, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent:

QPushButton button = parentWidget->findChild<QPushButton >(“button1”);

This example returns a QListWidget child of parentWidget:

QListWidget list = parentWidget->findChild<QListWidget >();

This example returns a child QPushButton of parentWidget (its direct parent) named "button1":

QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);

This example returns a QListWidget child of parentWidget, its direct parent:

QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);

See also findChildren().

source

pub unsafe fn find_child_q_object_1a( &self, a_name: impl CastInto<Ref<QString>> ) -> QPtr<QObject>

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QObject* QObject::findChild<QObject*>(const QString& aName = …) const.

C++ documentation:

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent:

QPushButton button = parentWidget->findChild<QPushButton >(“button1”);

This example returns a QListWidget child of parentWidget:

QListWidget list = parentWidget->findChild<QListWidget >();

This example returns a child QPushButton of parentWidget (its direct parent) named "button1":

QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);

This example returns a QListWidget child of parentWidget, its direct parent:

QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);

See also findChildren().

source

pub unsafe fn find_child_q_object_0a(&self) -> QPtr<QObject>

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QObject* QObject::findChild<QObject*>() const.

C++ documentation:

Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child QPushButton of parentWidget named "button1", even if the button isn't a direct child of the parent:

QPushButton button = parentWidget->findChild<QPushButton >(“button1”);

This example returns a QListWidget child of parentWidget:

QListWidget list = parentWidget->findChild<QListWidget >();

This example returns a child QPushButton of parentWidget (its direct parent) named "button1":

QPushButton button = parentWidget->findChild<QPushButton >(“button1”, Qt::FindDirectChildrenOnly);

This example returns a QListWidget child of parentWidget, its direct parent:

QListWidget list = parentWidget->findChild<QListWidget >(QString(), Qt::FindDirectChildrenOnly);

See also findChildren().

source

pub unsafe fn find_children_q_object_q_string_q_flags_find_child_option( &self, a_name: impl CastInto<Ref<QString>>, options: QFlags<FindChildOption> ) -> CppBox<QListOfQObject>

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QString& aName = …, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname:

QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);

This example returns all QPushButtons that are children of parentWidget:

QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();

This example returns all QPushButtons that are immediate children of parentWidget:

QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);

See also findChild().

source

pub unsafe fn find_children_q_object_q_reg_exp_q_flags_find_child_option( &self, re: impl CastInto<Ref<QRegExp>>, options: QFlags<FindChildOption> ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegExp& re, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression regExp, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

source

pub unsafe fn find_children_q_object_q_regular_expression_q_flags_find_child_option( &self, re: impl CastInto<Ref<QRegularExpression>>, options: QFlags<FindChildOption> ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegularExpression& re, QFlags<Qt::FindChildOption> options = …) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression re, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

This function was introduced in Qt 5.0.

source

pub unsafe fn find_children_q_object_q_string( &self, a_name: impl CastInto<Ref<QString>> ) -> CppBox<QListOfQObject>

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QString& aName = …) const.

C++ documentation:

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname:

QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);

This example returns all QPushButtons that are children of parentWidget:

QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();

This example returns all QPushButtons that are immediate children of parentWidget:

QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);

See also findChild().

source

pub unsafe fn find_children_q_object(&self) -> CppBox<QListOfQObject>

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>() const.

C++ documentation:

Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. Omitting the name argument causes all object names to be matched. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname:

QList<QWidget > widgets = parentWidget.findChildren<QWidget >(“widgetname”);

This example returns all QPushButtons that are children of parentWidget:

QList<QPushButton > allPButtons = parentWidget.findChildren<QPushButton >();

This example returns all QPushButtons that are immediate children of parentWidget:

QList<QPushButton > childButtons = parentWidget.findChildren<QPushButton >(QString(), Qt::FindDirectChildrenOnly);

See also findChild().

source

pub unsafe fn find_children_q_object_q_reg_exp( &self, re: impl CastInto<Ref<QRegExp>> ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegExp& re) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression regExp, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

source

pub unsafe fn find_children_q_object_q_regular_expression( &self, re: impl CastInto<Ref<QRegularExpression>> ) -> CppBox<QListOfQObject>

This function overloads findChildren().

Calls C++ function: QList<QObject*> QObject::findChildren<QObject*>(const QRegularExpression& re) const.

C++ documentation:

This function overloads findChildren().

Returns the children of this object that can be cast to type T and that have names matching the regular expression re, or an empty list if there are no such objects. The search is performed recursively, unless options specifies the option FindDirectChildrenOnly.

This function was introduced in Qt 5.0.

source

pub unsafe fn inherits(&self, classname: *const i8) -> bool

Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.

Calls C++ function: bool QObject::inherits(const char* classname) const.

C++ documentation:

Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.

A class is considered to inherit itself.

Example:

QTimer *timer = new QTimer; // QTimer inherits QObject timer->inherits(“QTimer”); // returns true timer->inherits(“QObject”); // returns true timer->inherits(“QAbstractButton”); // returns false

// QVBoxLayout inherits QObject and QLayoutItem QVBoxLayout *layout = new QVBoxLayout; layout->inherits(“QObject”); // returns true layout->inherits(“QLayoutItem”); // returns true (even though QLayoutItem is not a QObject)

If you need to determine whether an object is an instance of a particular class for the purpose of casting it, consider using qobject_cast<Type *>(object) instead.

See also metaObject() and qobject_cast().

source

pub unsafe fn install_event_filter( &self, filter_obj: impl CastInto<Ptr<QObject>> )

Installs an event filter filterObj on this object. For example:

Calls C++ function: void QObject::installEventFilter(QObject* filterObj).

C++ documentation:

Installs an event filter filterObj on this object. For example:


  monitoredObj->installEventFilter(filterObj);

An event filter is an object that receives all events that are sent to this object. The filter can either stop the event or forward it to this object. The event filter filterObj receives events via its eventFilter() function. The eventFilter() function must return true if the event should be filtered, (i.e. stopped); otherwise it must return false.

If multiple event filters are installed on a single object, the filter that was installed last is activated first.

Here's a KeyPressEater class that eats the key presses of its monitored objects:

class KeyPressEater : public QObject { Q_OBJECT ...

protected: bool eventFilter(QObject obj, QEvent event); };

bool KeyPressEater::eventFilter(QObject obj, QEvent event) { if (event->type() == QEvent::KeyPress) { QKeyEvent keyEvent = static_cast<QKeyEvent >(event); qDebug(“Ate key press %d”, keyEvent->key()); return true; } else { // standard event processing return QObject::eventFilter(obj, event); } }

And here's how to install it on two widgets:

KeyPressEater keyPressEater = new KeyPressEater(this); QPushButton pushButton = new QPushButton(this); QListView *listView = new QListView(this);

pushButton->installEventFilter(keyPressEater); listView->installEventFilter(keyPressEater);

The QShortcut class, for example, uses this technique to intercept shortcut key presses.

Warning: If you delete the receiver object in your eventFilter() function, be sure to return true. If you return false, Qt sends the event to the deleted object and the program will crash.

Note that the filtering object must be in the same thread as this object. If filterObj is in a different thread, this function does nothing. If either filterObj or this object are moved to a different thread after calling this function, the event filter will not be called until both objects have the same thread affinity again (it is not removed).

See also removeEventFilter(), eventFilter(), and event().

source

pub unsafe fn is_widget_type(&self) -> bool

Returns true if the object is a widget; otherwise returns false.

Calls C++ function: bool QObject::isWidgetType() const.

C++ documentation:

Returns true if the object is a widget; otherwise returns false.

Calling this function is equivalent to calling inherits("QWidget"), except that it is much faster.

source

pub unsafe fn is_window_type(&self) -> bool

Returns true if the object is a window; otherwise returns false.

Calls C++ function: bool QObject::isWindowType() const.

C++ documentation:

Returns true if the object is a window; otherwise returns false.

Calling this function is equivalent to calling inherits("QWindow"), except that it is much faster.

source

pub unsafe fn kill_timer(&self, id: i32)

Kills the timer with timer identifier, id.

Calls C++ function: void QObject::killTimer(int id).

C++ documentation:

Kills the timer with timer identifier, id.

The timer identifier is returned by startTimer() when a timer event is started.

See also timerEvent() and startTimer().

source

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

Returns a pointer to the meta-object of this object.

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

C++ documentation:

Returns a pointer to the meta-object of this object.

A meta-object contains information about a class that inherits QObject, e.g. class name, superclass name, properties, signals and slots. Every QObject subclass that contains the Q_OBJECT macro will have a meta-object.

The meta-object information is required by the signal/slot connection mechanism and the property system. The inherits() function also makes use of the meta-object.

If you have no pointer to an actual object instance but still want to access the meta-object of a class, you can use staticMetaObject.

Example:

QObject *obj = new QPushButton; obj->metaObject()->className(); // returns “QPushButton”

QPushButton::staticMetaObject.className(); // returns “QPushButton”

See also staticMetaObject.

source

pub unsafe fn move_to_thread(&self, thread: impl CastInto<Ptr<QThread>>)

Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.

Calls C++ function: void QObject::moveToThread(QThread* thread).

C++ documentation:

Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.

To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example:

myObject->moveToThread(QApplication::instance()->thread());

If targetThread is zero, all event processing for this object and its children stops.

Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with the same interval) in the targetThread. As a result, constantly moving an object between threads can postpone timer events indefinitely.

A QEvent::ThreadChange event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the targetThread.

Warning: This function is not thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only "push" an object from the current thread to another thread, it cannot "pull" an object from any arbitrary thread to the current thread.

See also thread().

source

pub unsafe fn object_name(&self) -> CppBox<QString>

This property holds the name of this object

Calls C++ function: QString QObject::objectName() const.

C++ documentation:

This property holds the name of this object

You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren().

qDebug(“MyClass::setPrecision(): (%s) invalid precision %f”, qPrintable(objectName()), newPrecision);

By default, this property contains an empty string.

Access functions:

QString objectName() const
void setObjectName(const QString &name)

Notifier signal:

void objectNameChanged(const QString &objectName)[see note below]

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

See also metaObject() and QMetaObject::className().

source

pub unsafe fn parent(&self) -> QPtr<QObject>

Returns a pointer to the parent object.

Calls C++ function: QObject* QObject::parent() const.

C++ documentation:

Returns a pointer to the parent object.

See also setParent() and children().

source

pub unsafe fn property(&self, name: *const i8) -> CppBox<QVariant>

Returns the value of the object's name property.

Calls C++ function: QVariant QObject::property(const char* name) const.

C++ documentation:

Returns the value of the object’s name property.

If no such property exists, the returned variant is invalid.

Information about all available properties is provided through the metaObject() and dynamicPropertyNames().

See also setProperty(), QVariant::isValid(), metaObject(), and dynamicPropertyNames().

source

pub unsafe fn qt_metacall( &self, arg1: Call, arg2: i32, arg3: *mut *mut c_void ) -> i32

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

source

pub unsafe fn qt_metacast(&self, arg1: *const i8) -> *mut c_void

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

source

pub unsafe fn remove_event_filter(&self, obj: impl CastInto<Ptr<QObject>>)

Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.

Calls C++ function: void QObject::removeEventFilter(QObject* obj).

C++ documentation:

Removes an event filter object obj from this object. The request is ignored if such an event filter has not been installed.

All event filters for this object are automatically removed when this object is destroyed.

It is always safe to remove an event filter, even during event filter activation (i.e. from the eventFilter() function).

See also installEventFilter(), eventFilter(), and event().

source

pub unsafe fn set_object_name(&self, name: impl CastInto<Ref<QString>>)

This property holds the name of this object

Calls C++ function: void QObject::setObjectName(const QString& name).

C++ documentation:

This property holds the name of this object

You can find an object by name (and type) using findChild(). You can find a set of objects with findChildren().

qDebug(“MyClass::setPrecision(): (%s) invalid precision %f”, qPrintable(objectName()), newPrecision);

By default, this property contains an empty string.

Access functions:

QString objectName() const
void setObjectName(const QString &name)

Notifier signal:

void objectNameChanged(const QString &objectName)[see note below]

Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.

See also metaObject() and QMetaObject::className().

source

pub unsafe fn set_parent(&self, parent: impl CastInto<Ptr<QObject>>)

Makes the object a child of parent.

Calls C++ function: void QObject::setParent(QObject* parent).

C++ documentation:

Makes the object a child of parent.

See also parent() and children().

source

pub unsafe fn set_property( &self, name: *const i8, value: impl CastInto<Ref<QVariant>> ) -> bool

Sets the value of the object's name property to value.

Calls C++ function: bool QObject::setProperty(const char* name, const QVariant& value).

C++ documentation:

Sets the value of the object’s name property to value.

If the property is defined in the class using Q_PROPERTY then true is returned on success and false otherwise. If the property is not defined using Q_PROPERTY, and therefore not listed in the meta-object, it is added as a dynamic property and false is returned.

Information about all available properties is provided through the metaObject() and dynamicPropertyNames().

Dynamic properties can be queried again using property() and can be removed by setting the property value to an invalid QVariant. Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent to be sent to the object.

Note: Dynamic properties starting with "_q_" are reserved for internal purposes.

See also property(), metaObject(), dynamicPropertyNames(), and QMetaProperty::write().

source

pub unsafe fn signals_blocked(&self) -> bool

Returns true if signals are blocked; otherwise returns false.

Calls C++ function: bool QObject::signalsBlocked() const.

C++ documentation:

Returns true if signals are blocked; otherwise returns false.

Signals are not blocked by default.

See also blockSignals() and QSignalBlocker.

source

pub unsafe fn start_timer_2a(&self, interval: i32, timer_type: TimerType) -> i32

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

Calls C++ function: int QObject::startTimer(int interval, Qt::TimerType timerType = …).

C++ documentation:

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.

The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.

If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.

Example:

class MyObject : public QObject { Q_OBJECT

public: MyObject(QObject *parent = 0);

protected: void timerEvent(QTimerEvent *event); };

MyObject::MyObject(QObject *parent) : QObject(parent) { startTimer(50); // 50-millisecond timer startTimer(1000); // 1-second timer startTimer(60000); // 1-minute timer

using namespace std::chrono; startTimer(milliseconds(50)); startTimer(seconds(1)); startTimer(minutes(1));

// since C++14 we can use std::chrono::duration literals, e.g.: startTimer(100ms); startTimer(5s); startTimer(2min); startTimer(1h); }

void MyObject::timerEvent(QTimerEvent *event) { qDebug() << “Timer ID:” << event->timerId(); }

Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.

The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.

See also timerEvent(), killTimer(), and QTimer::singleShot().

source

pub unsafe fn start_timer_1a(&self, interval: i32) -> i32

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

Calls C++ function: int QObject::startTimer(int interval).

C++ documentation:

Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.

A timer event will occur every interval milliseconds until killTimer() is called. If interval is 0, then the timer event occurs once every time there are no more window system events to process.

The virtual timerEvent() function is called with the QTimerEvent event parameter class when a timer event occurs. Reimplement this function to get timer events.

If multiple timers are running, the QTimerEvent::timerId() can be used to find out which timer was activated.

Example:

class MyObject : public QObject { Q_OBJECT

public: MyObject(QObject *parent = 0);

protected: void timerEvent(QTimerEvent *event); };

MyObject::MyObject(QObject *parent) : QObject(parent) { startTimer(50); // 50-millisecond timer startTimer(1000); // 1-second timer startTimer(60000); // 1-minute timer

using namespace std::chrono; startTimer(milliseconds(50)); startTimer(seconds(1)); startTimer(minutes(1));

// since C++14 we can use std::chrono::duration literals, e.g.: startTimer(100ms); startTimer(5s); startTimer(2min); startTimer(1h); }

void MyObject::timerEvent(QTimerEvent *event) { qDebug() << “Timer ID:” << event->timerId(); }

Note that QTimer's accuracy depends on the underlying operating system and hardware. The timerType argument allows you to customize the accuracy of the timer. See Qt::TimerType for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.

The QTimer class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a QBasicTimer class that is more lightweight than QTimer and less clumsy than using timer IDs directly.

See also timerEvent(), killTimer(), and QTimer::singleShot().

source

pub unsafe fn thread(&self) -> QPtr<QThread>

Returns the thread in which the object lives.

Calls C++ function: QThread* QObject::thread() const.

C++ documentation:

Returns the thread in which the object lives.

See also moveToThread().

Trait Implementations§

source§

impl Begin for QTextDocument

source§

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

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().

§

type Output = CppBox<QTextBlock>

Output type.
source§

impl CppDeletable for QTextDocument

source§

unsafe fn delete(&self)

Destroys the document.

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

C++ documentation:

Destroys the document.

source§

impl Deref for QTextDocument

source§

fn deref(&self) -> &QObject

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

§

type Target = QObject

The resulting type after dereferencing.
source§

impl DynamicCast<QTextDocument> for QObject

source§

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

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

source§

impl End for QTextDocument

source§

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

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().

§

type Output = CppBox<QTextBlock>

Output type.
source§

impl Size for QTextDocument

source§

unsafe fn size(&self) -> usize

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().

source§

impl StaticDowncast<QTextDocument> for QObject

source§

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

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

source§

impl StaticUpcast<QObject> for QTextDocument

source§

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

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.