Struct qt_gui::QTextFragment

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

The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.

C++ class: QTextFragment.

C++ documentation:

The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.

A text fragment describes a piece of text that is stored with a single character format. Text in which the character format changes can be represented by sequences of text fragments with different formats.

If the user edits the text in a fragment and introduces a different character format, the fragment's text will be split at each point where the format changes, and new fragments will be created. For example, changing the style of some text in the middle of a sentence will cause the fragment to be broken into three separate fragments: the first and third with the same format as before, and the second with the new style. The first fragment will contain the text from the beginning of the sentence, the second will contain the text from the middle, and the third takes the text from the end of the sentence.

A fragment's text and character format can be obtained with the text() and charFormat() functions. The length() function gives the length of the text in the fragment. position() gives the position in the document of the start of the fragment. To determine whether the fragment contains a particular position within the document, use the contains() function.

Implementations§

source§

impl QTextFragment

source

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

Returns the text fragment's character format.

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

C++ documentation:

Returns the text fragment’s character format.

See also text().

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 fragment's character format.

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

C++ documentation:

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

See also QTextDocument::allFormats().

source

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

Returns true if the text fragment contains the text at the given position in the document; otherwise returns false.

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

C++ documentation:

Returns true if the text fragment contains the text at the given position in the document; otherwise returns false.

source

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

Assigns the content (text and format) of the other text fragment to this text fragment.

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

C++ documentation:

Assigns the content (text and format) of the other text fragment to this text fragment.

source

pub unsafe fn glyph_runs_2a( &self, from: c_int, length: c_int ) -> CppBox<QListOfQGlyphRun>

Returns the glyphs corresponding to len characters of this text fragment starting at position pos. The positions of the glyphs are relative to the position of the QTextBlock's layout.

Calls C++ function: QList<QGlyphRun> QTextFragment::glyphRuns(int from = …, int length = …) const.

C++ documentation:

Returns the glyphs corresponding to len characters of this text fragment starting at position pos. The positions of the glyphs are relative to the position of the QTextBlock’s layout.

If pos is less than zero, it will default to the start of the QTextFragment. If len is less than zero, it will default to the length of the fragment.

See also QGlyphRun, QTextBlock::layout(), QTextLayout::position(), and QPainter::drawGlyphRun().

source

pub unsafe fn glyph_runs_1a(&self, from: c_int) -> CppBox<QListOfQGlyphRun>

Returns the glyphs corresponding to len characters of this text fragment starting at position pos. The positions of the glyphs are relative to the position of the QTextBlock's layout.

Calls C++ function: QList<QGlyphRun> QTextFragment::glyphRuns(int from = …) const.

C++ documentation:

Returns the glyphs corresponding to len characters of this text fragment starting at position pos. The positions of the glyphs are relative to the position of the QTextBlock’s layout.

If pos is less than zero, it will default to the start of the QTextFragment. If len is less than zero, it will default to the length of the fragment.

See also QGlyphRun, QTextBlock::layout(), QTextLayout::position(), and QPainter::drawGlyphRun().

source

pub unsafe fn glyph_runs_0a(&self) -> CppBox<QListOfQGlyphRun>

Returns the glyphs corresponding to len characters of this text fragment starting at position pos. The positions of the glyphs are relative to the position of the QTextBlock's layout.

Calls C++ function: QList<QGlyphRun> QTextFragment::glyphRuns() const.

C++ documentation:

Returns the glyphs corresponding to len characters of this text fragment starting at position pos. The positions of the glyphs are relative to the position of the QTextBlock’s layout.

If pos is less than zero, it will default to the start of the QTextFragment. If len is less than zero, it will default to the length of the fragment.

See also QGlyphRun, QTextBlock::layout(), QTextLayout::position(), and QPainter::drawGlyphRun().

source

pub unsafe fn is_valid(&self) -> bool

Returns true if this is a valid text fragment (i.e. has a valid position in a document); otherwise returns false.

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

C++ documentation:

Returns true if this is a valid text fragment (i.e. has a valid position in a document); otherwise returns false.

source

pub unsafe fn length(&self) -> c_int

Returns the number of characters in the text fragment.

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

C++ documentation:

Returns the number of characters in the text fragment.

See also text().

source

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

Creates a new empty text fragment.

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

C++ documentation:

Creates a new empty text fragment.

source

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

Copies the content (text and format) of the other text fragment to this text fragment.

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

C++ documentation:

Copies the content (text and format) of the other text fragment to this text fragment.

source

pub unsafe fn position(&self) -> c_int

Returns the position of this text fragment in the document.

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

C++ documentation:

Returns the position of this text fragment in the document.

source

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

Returns the text fragment's as plain text.

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

C++ documentation:

Returns the text fragment’s as plain text.

See also length() and charFormat().

Trait Implementations§

source§

impl CppDeletable for QTextFragment

source§

unsafe fn delete(&self)

The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.

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

C++ documentation:

The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.

A text fragment describes a piece of text that is stored with a single character format. Text in which the character format changes can be represented by sequences of text fragments with different formats.

If the user edits the text in a fragment and introduces a different character format, the fragment's text will be split at each point where the format changes, and new fragments will be created. For example, changing the style of some text in the middle of a sentence will cause the fragment to be broken into three separate fragments: the first and third with the same format as before, and the second with the new style. The first fragment will contain the text from the beginning of the sentence, the second will contain the text from the middle, and the third takes the text from the end of the sentence.

A fragment's text and character format can be obtained with the text() and charFormat() functions. The length() function gives the length of the text in the fragment. position() gives the position in the document of the start of the fragment. To determine whether the fragment contains a particular position within the document, use the contains() function.

source§

impl Lt<Ref<QTextFragment>> for QTextFragment

source§

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

Returns true if this text fragment appears earlier in the document than the other text fragment; otherwise returns false.

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

C++ documentation:

Returns true if this text fragment appears earlier in the document than the other text fragment; otherwise returns false.

source§

impl PartialEq<Ref<QTextFragment>> for QTextFragment

source§

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

Returns true if this text fragment is the same (at the same position) as the other text fragment; otherwise returns false.

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

C++ documentation:

Returns true if this text fragment is the same (at the same position) as the other text fragment; otherwise returns false.

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.