Struct qt_gui::QTextBlock

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

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

C++ class: QTextBlock.

C++ documentation:

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

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

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

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

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

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

Implementations§

source§

impl QTextBlock

source

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

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

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

C++ documentation:

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

See also end().

source

pub unsafe fn block_format(&self) -> CppBox<QTextBlockFormat>

Returns the QTextBlockFormat that describes block-specific properties.

Calls C++ function: QTextBlockFormat QTextBlock::blockFormat() const.

C++ documentation:

Returns the QTextBlockFormat that describes block-specific properties.

See also charFormat().

source

pub unsafe fn block_format_index(&self) -> c_int

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

Calls C++ function: int QTextBlock::blockFormatIndex() const.

C++ documentation:

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

See also QTextDocument::allFormats().

source

pub unsafe fn block_number(&self) -> c_int

Returns the number of this block, or -1 if the block is invalid.

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

C++ documentation:

Returns the number of this block, or -1 if the block is invalid.

This function was introduced in Qt 4.4.

See also QTextCursor::blockNumber().

source

pub unsafe fn char_format(&self) -> CppBox<QTextCharFormat>

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

Calls C++ function: QTextCharFormat QTextBlock::charFormat() const.

C++ documentation:

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

See also blockFormat().

source

pub unsafe fn char_format_index(&self) -> c_int

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

Calls C++ function: int QTextBlock::charFormatIndex() const.

C++ documentation:

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

See also QTextDocument::allFormats().

source

pub unsafe fn clear_layout(&self)

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

Calls C++ function: void QTextBlock::clearLayout().

C++ documentation:

Clears the QTextLayout that is used to lay out and display the block’s contents.

This function was introduced in Qt 4.4.

See also layout().

source

pub unsafe fn contains(&self, position: c_int) -> bool

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

Calls C++ function: bool QTextBlock::contains(int position) const.

C++ documentation:

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

source

pub unsafe fn copy_from( &self, o: impl CastInto<Ref<QTextBlock>> ) -> Ref<QTextBlock>

Assigns the other text block to this text block.

Calls C++ function: QTextBlock& QTextBlock::operator=(const QTextBlock& o).

C++ documentation:

Assigns the other text block to this text block.

source

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

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

Calls C++ function: const QTextDocument* QTextBlock::document() const.

C++ documentation:

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

source

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

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

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

C++ documentation:

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

See also begin(), next(), and previous().

source

pub unsafe fn first_line_number(&self) -> c_int

Returns the first line number of this block, or -1 if the block is invalid. Unless the layout supports it, the line number is identical to the block number.

Calls C++ function: int QTextBlock::firstLineNumber() const.

C++ documentation:

Returns the first line number of this block, or -1 if the block is invalid. Unless the layout supports it, the line number is identical to the block number.

This function was introduced in Qt 4.5.

See also QTextBlock::blockNumber().

source

pub unsafe fn fragment_index(&self) -> c_int

Calls C++ function: int QTextBlock::fragmentIndex() const.

source

pub unsafe fn is_valid(&self) -> bool

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

Calls C++ function: bool QTextBlock::isValid() const.

C++ documentation:

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

source

pub unsafe fn is_visible(&self) -> bool

Returns true if the block is visible; otherwise returns false.

Calls C++ function: bool QTextBlock::isVisible() const.

C++ documentation:

Returns true if the block is visible; otherwise returns false.

This function was introduced in Qt 4.4.

See also setVisible().

source

pub unsafe fn layout(&self) -> Ptr<QTextLayout>

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

Calls C++ function: QTextLayout* QTextBlock::layout() const.

C++ documentation:

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

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

See also clearLayout().

source

pub unsafe fn length(&self) -> c_int

Returns the length of the block in characters.

Calls C++ function: int QTextBlock::length() const.

C++ documentation:

Returns the length of the block in characters.

Note: The length returned includes all formatting characters, for example, newline.

See also text(), charFormat(), and blockFormat().

source

pub unsafe fn line_count(&self) -> c_int

Returns the line count. Not all document layouts support this feature.

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

C++ documentation:

Returns the line count. Not all document layouts support this feature.

This function was introduced in Qt 4.5.

See also setLineCount().

source

pub unsafe fn new() -> CppBox<QTextBlock>

Copies the other text block's attributes to this text block.

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

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QTextBlock::QTextBlock(const QTextBlock &other):

Copies the other text block’s attributes to this text block.

source

pub unsafe fn new_copy(o: impl CastInto<Ref<QTextBlock>>) -> CppBox<QTextBlock>

Copies the other text block's attributes to this text block.

Calls C++ function: [constructor] void QTextBlock::QTextBlock(const QTextBlock& o).

C++ documentation:

Copies the other text block’s attributes to this text block.

source

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

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

Calls C++ function: QTextBlock QTextBlock::next() const.

C++ documentation:

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

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

See also previous(), begin(), and end().

source

pub unsafe fn position(&self) -> c_int

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

Calls C++ function: int QTextBlock::position() const.

C++ documentation:

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

source

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

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

Calls C++ function: QTextBlock QTextBlock::previous() const.

C++ documentation:

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

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

See also next(), begin(), and end().

source

pub unsafe fn revision(&self) -> c_int

Returns the blocks revision.

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

C++ documentation:

Returns the blocks revision.

This function was introduced in Qt 4.4.

See also setRevision() and QTextDocument::revision().

source

pub unsafe fn set_line_count(&self, count: c_int)

Sets the line count to count.

Calls C++ function: void QTextBlock::setLineCount(int count).

C++ documentation:

Sets the line count to count.

This function was introduced in Qt 4.5.

See also lineCount().

source

pub unsafe fn set_revision(&self, rev: c_int)

Sets a blocks revision to rev.

Calls C++ function: void QTextBlock::setRevision(int rev).

C++ documentation:

Sets a blocks revision to rev.

This function was introduced in Qt 4.4.

See also revision() and QTextDocument::revision().

source

pub unsafe fn set_user_data(&self, data: impl CastInto<Ptr<QTextBlockUserData>>)

Attaches the given data object to the text block.

Calls C++ function: void QTextBlock::setUserData(QTextBlockUserData* data).

C++ documentation:

Attaches the given data object to the text block.

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

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

This function was introduced in Qt 4.1.

See also userData().

source

pub unsafe fn set_user_state(&self, state: c_int)

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

Calls C++ function: void QTextBlock::setUserState(int state).

C++ documentation:

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

This function was introduced in Qt 4.1.

See also userState().

source

pub unsafe fn set_visible(&self, visible: bool)

Sets the block's visibility to visible.

Calls C++ function: void QTextBlock::setVisible(bool visible).

C++ documentation:

Sets the block’s visibility to visible.

This function was introduced in Qt 4.4.

See also isVisible().

source

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

Returns the block's contents as plain text.

Calls C++ function: QString QTextBlock::text() const.

C++ documentation:

Returns the block’s contents as plain text.

See also length(), charFormat(), and blockFormat().

source

pub unsafe fn text_direction(&self) -> LayoutDirection

Returns the resolved text direction.

Calls C++ function: Qt::LayoutDirection QTextBlock::textDirection() const.

C++ documentation:

Returns the resolved text direction.

If the block has no explicit direction set, it will resolve the direction from the blocks content. Returns either Qt::LeftToRight or Qt::RightToLeft.

This function was introduced in Qt 4.7.

See also QTextFormat::layoutDirection(), QString::isRightToLeft(), and Qt::LayoutDirection.

source

pub unsafe fn text_formats(&self) -> CppBox<QVectorOfFormatRange>

Returns the block's text format options as a list of continuous ranges of QTextCharFormat. The range's character format is used when inserting text within the range boundaries.

Calls C++ function: QVector<QTextLayout::FormatRange> QTextBlock::textFormats() const.

C++ documentation:

Returns the block’s text format options as a list of continuous ranges of QTextCharFormat. The range’s character format is used when inserting text within the range boundaries.

This function was introduced in Qt 5.3.

See also charFormat() and blockFormat().

source

pub unsafe fn text_list(&self) -> QPtr<QTextList>

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

Calls C++ function: QTextList* QTextBlock::textList() const.

C++ documentation:

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

source

pub unsafe fn user_data(&self) -> Ptr<QTextBlockUserData>

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

Calls C++ function: QTextBlockUserData* QTextBlock::userData() const.

C++ documentation:

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

This function was introduced in Qt 4.1.

See also setUserData().

source

pub unsafe fn user_state(&self) -> c_int

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

Calls C++ function: int QTextBlock::userState() const.

C++ documentation:

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

This function was introduced in Qt 4.1.

See also setUserState().

Trait Implementations§

source§

impl Begin for QTextBlock

source§

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

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

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

C++ documentation:

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

See also end().

§

type Output = CppBox<Iterator>

Output type.
source§

impl CppDeletable for QTextBlock

source§

unsafe fn delete(&self)

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

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

C++ documentation:

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

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

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

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

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

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

source§

impl End for QTextBlock

source§

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

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

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

C++ documentation:

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

See also begin(), next(), and previous().

§

type Output = CppBox<Iterator>

Output type.
source§

impl Lt<Ref<QTextBlock>> for QTextBlock

source§

unsafe fn lt(&self, o: &Ref<QTextBlock>) -> bool

Returns true if this text block occurs before the other text block in the document.

Calls C++ function: bool QTextBlock::operator<(const QTextBlock& o) const.

C++ documentation:

Returns true if this text block occurs before the other text block in the document.

source§

impl PartialEq<Ref<QTextBlock>> for QTextBlock

source§

fn eq(&self, o: &Ref<QTextBlock>) -> bool

Returns true if this text block is the same as the other text block.

Calls C++ function: bool QTextBlock::operator==(const QTextBlock& o) const.

C++ documentation:

Returns true if this text block is the same as the other text block.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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.