Struct qt_gui::QTextLine

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

The QTextLine class represents a line of text inside a QTextLayout.

C++ class: QTextLine.

C++ documentation:

The QTextLine class represents a line of text inside a QTextLayout.

A text line is usually created by QTextLayout::createLine().

After being created, the line can be filled using the setLineWidth() or setNumColumns() functions. A line has a number of attributes including the rectangle it occupies, rect(), its coordinates, x() and y(), its textLength(), width() and naturalTextWidth(), and its ascent() and descent() relative to the text. The position of the cursor in terms of the line is available from cursorToX() and its inverse from xToCursor(). A line can be moved with setPosition().

Implementations§

source§

impl QTextLine

source

pub unsafe fn ascent(&self) -> c_double

Returns the line's ascent.

Calls C++ function: double QTextLine::ascent() const.

C++ documentation:

Returns the line’s ascent.

See also descent() and height().

source

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

The QTextLine class represents a line of text inside a QTextLayout.

Calls C++ function: QTextLine& QTextLine::operator=(const QTextLine& other).

C++ documentation:

The QTextLine class represents a line of text inside a QTextLayout.

A text line is usually created by QTextLayout::createLine().

After being created, the line can be filled using the setLineWidth() or setNumColumns() functions. A line has a number of attributes including the rectangle it occupies, rect(), its coordinates, x() and y(), its textLength(), width() and naturalTextWidth(), and its ascent() and descent() relative to the text. The position of the cursor in terms of the line is available from cursorToX() and its inverse from xToCursor(). A line can be moved with setPosition().

source

pub unsafe fn cursor_to_x_int_edge( &self, cursor_pos: *mut c_int, edge: Edge ) -> c_double

Converts the cursor position cursorPos to the corresponding x position inside the line, taking account of the edge.

Calls C++ function: double QTextLine::cursorToX(int* cursorPos, QTextLine::Edge edge = …) const.

C++ documentation:

Converts the cursor position cursorPos to the corresponding x position inside the line, taking account of the edge.

If cursorPos is not a valid cursor position, the nearest valid cursor position will be used instead, and cursorPos will be modified to point to this valid cursor position.

See also xToCursor().

source

pub unsafe fn cursor_to_x_int_edge2( &self, cursor_pos: c_int, edge: Edge ) -> c_double

This is an overloaded function.

Calls C++ function: double QTextLine::cursorToX(int cursorPos, QTextLine::Edge edge = …) const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn cursor_to_x_int(&self, cursor_pos: *mut c_int) -> c_double

Converts the cursor position cursorPos to the corresponding x position inside the line, taking account of the edge.

Calls C++ function: double QTextLine::cursorToX(int* cursorPos) const.

C++ documentation:

Converts the cursor position cursorPos to the corresponding x position inside the line, taking account of the edge.

If cursorPos is not a valid cursor position, the nearest valid cursor position will be used instead, and cursorPos will be modified to point to this valid cursor position.

See also xToCursor().

source

pub unsafe fn cursor_to_x_int2(&self, cursor_pos: c_int) -> c_double

This is an overloaded function.

Calls C++ function: double QTextLine::cursorToX(int cursorPos) const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn descent(&self) -> c_double

Returns the line's descent.

Calls C++ function: double QTextLine::descent() const.

C++ documentation:

Returns the line’s descent.

See also ascent() and height().

source

pub unsafe fn draw_3a( &self, p: impl CastInto<Ptr<QPainter>>, point: impl CastInto<Ref<QPointF>>, selection: impl CastInto<Ptr<FormatRange>> )

Draws a line on the given painter at the specified position. The selection is reserved for internal use.

Calls C++ function: void QTextLine::draw(QPainter* p, const QPointF& point, const QTextLayout::FormatRange* selection = …) const.

C++ documentation:

Draws a line on the given painter at the specified position. The selection is reserved for internal use.

source

pub unsafe fn draw_2a( &self, p: impl CastInto<Ptr<QPainter>>, point: impl CastInto<Ref<QPointF>> )

Draws a line on the given painter at the specified position. The selection is reserved for internal use.

Calls C++ function: void QTextLine::draw(QPainter* p, const QPointF& point) const.

C++ documentation:

Draws a line on the given painter at the specified position. The selection is reserved for internal use.

source

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

Returns the glyph indexes and positions for all glyphs in this QTextLine for characters in the range defined by from and length. The from index is relative to the beginning of the text in the containing QTextLayout, and the range must be within the range of QTextLine as given by functions textStart() and textLength().

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

C++ documentation:

Returns the glyph indexes and positions for all glyphs in this QTextLine for characters in the range defined by from and length. The from index is relative to the beginning of the text in the containing QTextLayout, and the range must be within the range of QTextLine as given by functions textStart() and textLength().

If from is negative, it will default to textStart(), and if length is negative it will default to the return value of textLength().

This function was introduced in Qt 5.0.

See also QTextLayout::glyphRuns().

source

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

Returns the glyph indexes and positions for all glyphs in this QTextLine for characters in the range defined by from and length. The from index is relative to the beginning of the text in the containing QTextLayout, and the range must be within the range of QTextLine as given by functions textStart() and textLength().

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

C++ documentation:

Returns the glyph indexes and positions for all glyphs in this QTextLine for characters in the range defined by from and length. The from index is relative to the beginning of the text in the containing QTextLayout, and the range must be within the range of QTextLine as given by functions textStart() and textLength().

If from is negative, it will default to textStart(), and if length is negative it will default to the return value of textLength().

This function was introduced in Qt 5.0.

See also QTextLayout::glyphRuns().

source

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

Returns the glyph indexes and positions for all glyphs in this QTextLine for characters in the range defined by from and length. The from index is relative to the beginning of the text in the containing QTextLayout, and the range must be within the range of QTextLine as given by functions textStart() and textLength().

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

C++ documentation:

Returns the glyph indexes and positions for all glyphs in this QTextLine for characters in the range defined by from and length. The from index is relative to the beginning of the text in the containing QTextLayout, and the range must be within the range of QTextLine as given by functions textStart() and textLength().

If from is negative, it will default to textStart(), and if length is negative it will default to the return value of textLength().

This function was introduced in Qt 5.0.

See also QTextLayout::glyphRuns().

source

pub unsafe fn height(&self) -> c_double

Returns the line's height. This is equal to ascent() + descent() if leading is not included. If leading is included, this equals to ascent() + descent() + leading().

Calls C++ function: double QTextLine::height() const.

C++ documentation:

Returns the line’s height. This is equal to ascent() + descent() if leading is not included. If leading is included, this equals to ascent() + descent() + leading().

See also ascent(), descent(), leading(), and setLeadingIncluded().

source

pub unsafe fn horizontal_advance(&self) -> c_double

Returns the horizontal advance of the text. The advance of the text is the distance from its position to the next position at which text would naturally be drawn.

Calls C++ function: double QTextLine::horizontalAdvance() const.

C++ documentation:

Returns the horizontal advance of the text. The advance of the text is the distance from its position to the next position at which text would naturally be drawn.

By adding the advance to the position of the text line and using this as the position of a second text line, you will be able to position the two lines side-by-side without gaps in-between.

This function was introduced in Qt 4.7.

source

pub unsafe fn is_valid(&self) -> bool

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

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

C++ documentation:

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

source

pub unsafe fn leading(&self) -> c_double

Returns the line's leading.

Calls C++ function: double QTextLine::leading() const.

C++ documentation:

Returns the line’s leading.

This function was introduced in Qt 4.6.

See also ascent(), descent(), and height().

source

pub unsafe fn leading_included(&self) -> bool

Returns true if positive leading is included into the line's height; otherwise returns false.

Calls C++ function: bool QTextLine::leadingIncluded() const.

C++ documentation:

Returns true if positive leading is included into the line’s height; otherwise returns false.

By default, leading is not included.

This function was introduced in Qt 4.6.

See also setLeadingIncluded().

source

pub unsafe fn line_number(&self) -> c_int

Returns the position of the line in the text engine.

Calls C++ function: int QTextLine::lineNumber() const.

C++ documentation:

Returns the position of the line in the text engine.

source

pub unsafe fn natural_text_rect(&self) -> CppBox<QRectF>

Returns the rectangle covered by the line.

Calls C++ function: QRectF QTextLine::naturalTextRect() const.

C++ documentation:

Returns the rectangle covered by the line.

source

pub unsafe fn natural_text_width(&self) -> c_double

Returns the width of the line that is occupied by text. This is always <= to width(), and is the minimum width that could be used by layout() without changing the line break position.

Calls C++ function: double QTextLine::naturalTextWidth() const.

C++ documentation:

Returns the width of the line that is occupied by text. This is always <= to width(), and is the minimum width that could be used by layout() without changing the line break position.

source

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

Creates an invalid line.

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

C++ documentation:

Creates an invalid line.

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QTextLine>> ) -> CppBox<QTextLine>

The QTextLine class represents a line of text inside a QTextLayout.

Calls C++ function: [constructor] void QTextLine::QTextLine(const QTextLine& other).

C++ documentation:

The QTextLine class represents a line of text inside a QTextLayout.

A text line is usually created by QTextLayout::createLine().

After being created, the line can be filled using the setLineWidth() or setNumColumns() functions. A line has a number of attributes including the rectangle it occupies, rect(), its coordinates, x() and y(), its textLength(), width() and naturalTextWidth(), and its ascent() and descent() relative to the text. The position of the cursor in terms of the line is available from cursorToX() and its inverse from xToCursor(). A line can be moved with setPosition().

source

pub unsafe fn position(&self) -> CppBox<QPointF>

Returns the line's position relative to the text layout's position.

Calls C++ function: QPointF QTextLine::position() const.

C++ documentation:

Returns the line’s position relative to the text layout’s position.

See also setPosition().

source

pub unsafe fn rect(&self) -> CppBox<QRectF>

Returns the line's bounding rectangle.

Calls C++ function: QRectF QTextLine::rect() const.

C++ documentation:

Returns the line’s bounding rectangle.

See also x(), y(), textLength(), and width().

source

pub unsafe fn set_leading_included(&self, included: bool)

Includes positive leading into the line's height if included is true; otherwise does not include leading.

Calls C++ function: void QTextLine::setLeadingIncluded(bool included).

C++ documentation:

Includes positive leading into the line’s height if included is true; otherwise does not include leading.

By default, leading is not included.

Note that negative leading is ignored, it must be handled in the code using the text lines by letting the lines overlap.

This function was introduced in Qt 4.6.

See also leadingIncluded().

source

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

Lays out the line with the given width. The line is filled from its starting position with as many characters as will fit into the line. In case the text cannot be split at the end of the line, it will be filled with additional characters to the next whitespace or end of the text.

Calls C++ function: void QTextLine::setLineWidth(double width).

C++ documentation:

Lays out the line with the given width. The line is filled from its starting position with as many characters as will fit into the line. In case the text cannot be split at the end of the line, it will be filled with additional characters to the next whitespace or end of the text.

source

pub unsafe fn set_num_columns_1a(&self, columns: c_int)

Lays out the line. The line is filled from its starting position with as many characters as are specified by numColumns. In case the text cannot be split until numColumns characters, the line will be filled with as many characters to the next whitespace or end of the text.

Calls C++ function: void QTextLine::setNumColumns(int columns).

C++ documentation:

Lays out the line. The line is filled from its starting position with as many characters as are specified by numColumns. In case the text cannot be split until numColumns characters, the line will be filled with as many characters to the next whitespace or end of the text.

source

pub unsafe fn set_num_columns_2a( &self, columns: c_int, alignment_width: c_double )

Lays out the line. The line is filled from its starting position with as many characters as are specified by numColumns. In case the text cannot be split until numColumns characters, the line will be filled with as many characters to the next whitespace or end of the text. The provided alignmentWidth is used as reference width for alignment.

Calls C++ function: void QTextLine::setNumColumns(int columns, double alignmentWidth).

C++ documentation:

Lays out the line. The line is filled from its starting position with as many characters as are specified by numColumns. In case the text cannot be split until numColumns characters, the line will be filled with as many characters to the next whitespace or end of the text. The provided alignmentWidth is used as reference width for alignment.

source

pub unsafe fn set_position(&self, pos: impl CastInto<Ref<QPointF>>)

Moves the line to position pos.

Calls C++ function: void QTextLine::setPosition(const QPointF& pos).

C++ documentation:

Moves the line to position pos.

See also position().

source

pub unsafe fn text_length(&self) -> c_int

Returns the length of the text in the line.

Calls C++ function: int QTextLine::textLength() const.

C++ documentation:

Returns the length of the text in the line.

See also naturalTextWidth().

source

pub unsafe fn text_start(&self) -> c_int

Returns the start of the line from the beginning of the string passed to the QTextLayout.

Calls C++ function: int QTextLine::textStart() const.

C++ documentation:

Returns the start of the line from the beginning of the string passed to the QTextLayout.

source

pub unsafe fn width(&self) -> c_double

Returns the line's width as specified by the layout() function.

Calls C++ function: double QTextLine::width() const.

C++ documentation:

Returns the line’s width as specified by the layout() function.

See also naturalTextWidth(), x(), y(), textLength(), and rect().

source

pub unsafe fn x(&self) -> c_double

Returns the line's x position.

Calls C++ function: double QTextLine::x() const.

C++ documentation:

Returns the line’s x position.

See also rect(), y(), textLength(), and width().

source

pub unsafe fn x_to_cursor_2a(&self, x: c_double, arg2: CursorPosition) -> c_int

Converts the x-coordinate x, to the nearest matching cursor position, depending on the cursor position type, cpos. Note that result cursor position includes possible preedit area text.

Calls C++ function: int QTextLine::xToCursor(double x, QTextLine::CursorPosition arg2 = …) const.

C++ documentation:

Converts the x-coordinate x, to the nearest matching cursor position, depending on the cursor position type, cpos. Note that result cursor position includes possible preedit area text.

See also cursorToX().

source

pub unsafe fn x_to_cursor_1a(&self, x: c_double) -> c_int

Converts the x-coordinate x, to the nearest matching cursor position, depending on the cursor position type, cpos. Note that result cursor position includes possible preedit area text.

Calls C++ function: int QTextLine::xToCursor(double x) const.

C++ documentation:

Converts the x-coordinate x, to the nearest matching cursor position, depending on the cursor position type, cpos. Note that result cursor position includes possible preedit area text.

See also cursorToX().

source

pub unsafe fn y(&self) -> c_double

Returns the line's y position.

Calls C++ function: double QTextLine::y() const.

C++ documentation:

Returns the line’s y position.

See also x(), rect(), textLength(), and width().

Trait Implementations§

source§

impl CppDeletable for QTextLine

source§

unsafe fn delete(&self)

The QTextLine class represents a line of text inside a QTextLayout.

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

C++ documentation:

The QTextLine class represents a line of text inside a QTextLayout.

A text line is usually created by QTextLayout::createLine().

After being created, the line can be filled using the setLineWidth() or setNumColumns() functions. A line has a number of attributes including the rectangle it occupies, rect(), its coordinates, x() and y(), its textLength(), width() and naturalTextWidth(), and its ascent() and descent() relative to the text. The position of the cursor in terms of the line is available from cursorToX() and its inverse from xToCursor(). A line can be moved with setPosition().

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.