Struct qt_core::QSize

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

The QSize class defines the size of a two-dimensional object using integer point precision.

C++ class: QSize.

C++ documentation:

The QSize class defines the size of a two-dimensional object using integer point precision.

A size is specified by a width() and a height(). It can be set in the constructor and changed using the setWidth(), setHeight(), or scale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose() function.

The isValid() function determines if a size is valid (a valid size has both width and height greater than or equal to zero). The isEmpty() function returns true if either of the width and height is less than, or equal to, zero, while the isNull() function returns true only if both the width and the height is zero.

Use the expandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo() function returns a size which holds the minimum height and width of this size and a given size.

QSize objects can be streamed as well as compared.

Implementations§

source§

impl QSize

source

pub unsafe fn add_assign(&self, arg1: impl CastInto<Ref<QSize>>) -> Ref<QSize>

Adds the given size to this size, and returns a reference to this size. For example:

Calls C++ function: QSize& QSize::operator+=(const QSize& arg1).

C++ documentation:

Adds the given size to this size, and returns a reference to this size. For example:


  QSize s( 3, 7);
  QSize r(-1, 4);
  s += r;

  // s becomes (2,11)

source

pub unsafe fn bounded_to( &self, arg1: impl CastInto<Ref<QSize>> ) -> CppBox<QSize>

Returns a size holding the minimum width and height of this size and the given otherSize.

Calls C++ function: QSize QSize::boundedTo(const QSize& arg1) const.

C++ documentation:

Returns a size holding the minimum width and height of this size and the given otherSize.

See also expandedTo() and scale().

source

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

The QSize class defines the size of a two-dimensional object using integer point precision.

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

C++ documentation:

The QSize class defines the size of a two-dimensional object using integer point precision.

A size is specified by a width() and a height(). It can be set in the constructor and changed using the setWidth(), setHeight(), or scale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose() function.

The isValid() function determines if a size is valid (a valid size has both width and height greater than or equal to zero). The isEmpty() function returns true if either of the width and height is less than, or equal to, zero, while the isNull() function returns true only if both the width and the height is zero.

Use the expandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo() function returns a size which holds the minimum height and width of this size and a given size.

QSize objects can be streamed as well as compared.

source

pub unsafe fn div_assign(&self, c: c_double) -> Ref<QSize>

This is an overloaded function.

Calls C++ function: QSize& QSize::operator/=(double c).

C++ documentation:

This is an overloaded function.

Divides both the width and height by the given divisor, and returns a reference to the size.

Note that the result is rounded to the nearest integer.

See also QSize::scale().

source

pub unsafe fn expanded_to( &self, arg1: impl CastInto<Ref<QSize>> ) -> CppBox<QSize>

Returns a size holding the maximum width and height of this size and the given otherSize.

Calls C++ function: QSize QSize::expandedTo(const QSize& arg1) const.

C++ documentation:

Returns a size holding the maximum width and height of this size and the given otherSize.

See also boundedTo() and scale().

source

pub unsafe fn grown_by(&self, m: impl CastInto<Ref<QMargins>>) -> CppBox<QSize>

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: QSize QSize::grownBy(QMargins m) const.

source

pub unsafe fn height(&self) -> c_int

Returns the height.

Calls C++ function: int QSize::height() const.

C++ documentation:

Returns the height.

See also width() and setHeight().

source

pub unsafe fn is_empty(&self) -> bool

Returns true if either of the width and height is less than or equal to 0; otherwise returns false.

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

C++ documentation:

Returns true if either of the width and height is less than or equal to 0; otherwise returns false.

See also isNull() and isValid().

source

pub unsafe fn is_null(&self) -> bool

Returns true if both the width and height is 0; otherwise returns false.

Calls C++ function: bool QSize::isNull() const.

C++ documentation:

Returns true if both the width and height is 0; otherwise returns false.

See also isValid() and isEmpty().

source

pub unsafe fn is_valid(&self) -> bool

Returns true if both the width and height is equal to or greater than 0; otherwise returns false.

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

C++ documentation:

Returns true if both the width and height is equal to or greater than 0; otherwise returns false.

See also isNull() and isEmpty().

source

pub unsafe fn mul_assign(&self, c: c_double) -> Ref<QSize>

This is an overloaded function.

Calls C++ function: QSize& QSize::operator*=(double c).

C++ documentation:

This is an overloaded function.

Multiplies both the width and height by the given factor, and returns a reference to the size.

Note that the result is rounded to the nearest integer.

See also scale().

source

pub unsafe fn new_0a() -> CppBox<QSize>

Constructs a size with an invalid width and height (i.e., isValid() returns false).

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

C++ documentation:

Constructs a size with an invalid width and height (i.e., isValid() returns false).

See also isValid().

source

pub unsafe fn new_2a(w: c_int, h: c_int) -> CppBox<QSize>

Constructs a size with the given width and height.

Calls C++ function: [constructor] void QSize::QSize(int w, int h).

C++ documentation:

Constructs a size with the given width and height.

See also setWidth() and setHeight().

source

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

The QSize class defines the size of a two-dimensional object using integer point precision.

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

C++ documentation:

The QSize class defines the size of a two-dimensional object using integer point precision.

A size is specified by a width() and a height(). It can be set in the constructor and changed using the setWidth(), setHeight(), or scale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose() function.

The isValid() function determines if a size is valid (a valid size has both width and height greater than or equal to zero). The isEmpty() function returns true if either of the width and height is less than, or equal to, zero, while the isNull() function returns true only if both the width and the height is zero.

Use the expandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo() function returns a size which holds the minimum height and width of this size and a given size.

QSize objects can be streamed as well as compared.

source

pub unsafe fn rheight(&self) -> *mut c_int

Returns a reference to the height.

Calls C++ function: int& QSize::rheight().

C++ documentation:

Returns a reference to the height.

Using a reference makes it possible to manipulate the height directly. For example:

QSize size(100, 10); size.rheight() += 5;

// size becomes (100,15)

See also rwidth() and setHeight().

source

pub unsafe fn rwidth(&self) -> *mut c_int

Returns a reference to the width.

Calls C++ function: int& QSize::rwidth().

C++ documentation:

Returns a reference to the width.

Using a reference makes it possible to manipulate the width directly. For example:

QSize size(100, 10); size.rwidth() += 20;

// size becomes (120,10)

See also rheight() and setWidth().

source

pub unsafe fn scale_3a(&self, w: c_int, h: c_int, mode: AspectRatioMode)

Scales the size to a rectangle with the given width and height, according to the specified mode:

Calls C++ function: void QSize::scale(int w, int h, Qt::AspectRatioMode mode).

C++ documentation:

Scales the size to a rectangle with the given width and height, according to the specified mode:

  • If mode is Qt::IgnoreAspectRatio, the size is set to (width, height).
  • If mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle as large as possible inside (width, height), preserving the aspect ratio.
  • If mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle as small as possible outside (width, height), preserving the aspect ratio.

Example:

QSize t1(10, 12); t1.scale(60, 60, Qt::IgnoreAspectRatio); // t1 is (60, 60)

QSize t2(10, 12); t2.scale(60, 60, Qt::KeepAspectRatio); // t2 is (50, 60)

QSize t3(10, 12); t3.scale(60, 60, Qt::KeepAspectRatioByExpanding); // t3 is (60, 72)

See also setWidth(), setHeight(), and scaled().

source

pub unsafe fn scale_2a( &self, s: impl CastInto<Ref<QSize>>, mode: AspectRatioMode )

This is an overloaded function.

Calls C++ function: void QSize::scale(const QSize& s, Qt::AspectRatioMode mode).

C++ documentation:

This is an overloaded function.

Scales the size to a rectangle with the given size, according to the specified mode.

source

pub unsafe fn scaled_3a( &self, w: c_int, h: c_int, mode: AspectRatioMode ) -> CppBox<QSize>

Return a size scaled to a rectangle with the given width and height, according to the specified mode.

Calls C++ function: QSize QSize::scaled(int w, int h, Qt::AspectRatioMode mode) const.

C++ documentation:

Return a size scaled to a rectangle with the given width and height, according to the specified mode.

This function was introduced in Qt 5.0.

See also scale().

source

pub unsafe fn scaled_2a( &self, s: impl CastInto<Ref<QSize>>, mode: AspectRatioMode ) -> CppBox<QSize>

This is an overloaded function.

Calls C++ function: QSize QSize::scaled(const QSize& s, Qt::AspectRatioMode mode) const.

C++ documentation:

This is an overloaded function.

Return a size scaled to a rectangle with the given size s, according to the specified mode.

This function was introduced in Qt 5.0.

source

pub unsafe fn set_height(&self, h: c_int)

Sets the height to the given height.

Calls C++ function: void QSize::setHeight(int h).

C++ documentation:

Sets the height to the given height.

See also rheight(), height(), and setWidth().

source

pub unsafe fn set_width(&self, w: c_int)

Sets the width to the given width.

Calls C++ function: void QSize::setWidth(int w).

C++ documentation:

Sets the width to the given width.

See also rwidth(), width(), and setHeight().

source

pub unsafe fn shrunk_by(&self, m: impl CastInto<Ref<QMargins>>) -> CppBox<QSize>

Available on cpp_lib_version="5.14.0" only.

Calls C++ function: QSize QSize::shrunkBy(QMargins m) const.

source

pub unsafe fn sub_assign(&self, arg1: impl CastInto<Ref<QSize>>) -> Ref<QSize>

Subtracts the given size from this size, and returns a reference to this size. For example:

Calls C++ function: QSize& QSize::operator-=(const QSize& arg1).

C++ documentation:

Subtracts the given size from this size, and returns a reference to this size. For example:


  QSize s( 3, 7);
  QSize r(-1, 4);
  s -= r;

  // s becomes (4,3)

source

pub unsafe fn transpose(&self)

Swaps the width and height values.

Calls C++ function: void QSize::transpose().

C++ documentation:

Swaps the width and height values.

See also setWidth(), setHeight(), and transposed().

source

pub unsafe fn transposed(&self) -> CppBox<QSize>

Returns a QSize with width and height swapped.

Calls C++ function: QSize QSize::transposed() const.

C++ documentation:

Returns a QSize with width and height swapped.

This function was introduced in Qt 5.0.

See also transpose().

source

pub unsafe fn width(&self) -> c_int

Returns the width.

Calls C++ function: int QSize::width() const.

C++ documentation:

Returns the width.

See also height() and setWidth().

Trait Implementations§

source§

impl Add<Ref<QSize>> for &QSize

source§

fn add(self, s2: Ref<QSize>) -> CppBox<QSize>

Calls C++ function: QSize operator+(const QSize& s1, const QSize& s2).

§

type Output = CppBox<QSize>

The resulting type after applying the + operator.
source§

impl CppDeletable for QSize

source§

unsafe fn delete(&self)

The QSize class defines the size of a two-dimensional object using integer point precision.

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

C++ documentation:

The QSize class defines the size of a two-dimensional object using integer point precision.

A size is specified by a width() and a height(). It can be set in the constructor and changed using the setWidth(), setHeight(), or scale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose() function.

The isValid() function determines if a size is valid (a valid size has both width and height greater than or equal to zero). The isEmpty() function returns true if either of the width and height is less than, or equal to, zero, while the isNull() function returns true only if both the width and the height is zero.

Use the expandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo() function returns a size which holds the minimum height and width of this size and a given size.

QSize objects can be streamed as well as compared.

source§

impl Div<f64> for &QSize

source§

fn div(self, c: c_double) -> CppBox<QSize>

Calls C++ function: QSize operator/(const QSize& s, double c).

§

type Output = CppBox<QSize>

The resulting type after applying the / operator.
source§

impl Mul<f64> for &QSize

source§

fn mul(self, c: c_double) -> CppBox<QSize>

Calls C++ function: QSize operator*(const QSize& s, double c).

§

type Output = CppBox<QSize>

The resulting type after applying the * operator.
source§

impl PartialEq<Ref<QSize>> for QSize

source§

fn eq(&self, s2: &Ref<QSize>) -> bool

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

Calls C++ function: bool operator==(const QSize& s1, const QSize& s2).

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.

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

impl Sub<Ref<QSize>> for &QSize

source§

fn sub(self, s2: Ref<QSize>) -> CppBox<QSize>

Calls C++ function: QSize operator-(const QSize& s1, const QSize& s2).

§

type Output = CppBox<QSize>

The resulting type after applying the - operator.

Auto Trait Implementations§

§

impl RefUnwindSafe for QSize

§

impl Send for QSize

§

impl Sync for QSize

§

impl Unpin for QSize

§

impl UnwindSafe for QSize

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.