pub struct SizeF<'a> { /* private fields */ }
Expand description
Notice these docs are heavy WIP and not very relevent yet
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.
The QSizeF class also provides the toSize() function returning a QSize copy of this size, constructed by rounding the width and height to the nearest integers.
QSizeF objects can be streamed as well as compared.
Licence
The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Implementations
sourceimpl<'a> SizeF<'a>
impl<'a> SizeF<'a>
pub fn new() -> SizeF<'a>
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns true
if both the width and height are 0.0 (ignoring the sign);
otherwise returns false.
See also: [is_valid()
]
[is_empty()
]
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if either of the width and height is less than or
equal to 0; otherwise returns false.
See also: [is_null()
]
[is_valid()
]
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true
if both the width and height is equal to or greater
than 0; otherwise returns false.
See also: [is_null()
]
[is_empty()
]
sourcepub fn set_width(&self, w: f32) -> &Self
pub fn set_width(&self, w: f32) -> &Self
Sets the width to the given width.
See also: [width()
]
[rwidth()
]
[set_height()
]
sourcepub fn set_height(&self, h: f32) -> &Self
pub fn set_height(&self, h: f32) -> &Self
Sets the height to the given height.
See also: [height()
]
[rheight()
]
[set_width()
]
sourcepub fn scale(&self, w: f32, h: f32, mode: AspectRatioMode) -> &Self
pub fn scale(&self, w: f32, h: f32, mode: AspectRatioMode) -> &Self
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:
See also: [set_width()
]
[set_height()
]
[scaled()
]
Overloads Scales the size to a rectangle with the given size, according to the specified mode.
Returns a size scaled to a rectangle with the given width and height, according to the specified mode.
See also: [scale()
]
Overloads Returns a size scaled to a rectangle with the given size s, according to the specified mode.
sourcepub fn scale_2<S: SizeFTrait<'a>>(&self, s: &S, mode: AspectRatioMode) -> &Self
pub fn scale_2<S: SizeFTrait<'a>>(&self, s: &S, mode: AspectRatioMode) -> &Self
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:
See also: [set_width()
]
[set_height()
]
[scaled()
]
Overloads Scales the size to a rectangle with the given size, according to the specified mode.
Returns a size scaled to a rectangle with the given width and height, according to the specified mode.
See also: [scale()
]
Overloads Returns a size scaled to a rectangle with the given size s, according to the specified mode.
sourcepub fn scaled(&self, w: f32, h: f32, mode: AspectRatioMode) -> SizeF<'_>
pub fn scaled(&self, w: f32, h: f32, mode: AspectRatioMode) -> SizeF<'_>
Returns a size scaled to a rectangle with the given width and height, according to the specified mode.
See also: [scale()
]
Overloads Returns a size scaled to a rectangle with the given size s, according to the specified mode.
sourcepub fn scaled_2<S: SizeFTrait<'a>>(
&self,
s: &S,
mode: AspectRatioMode
) -> SizeF<'_>
pub fn scaled_2<S: SizeFTrait<'a>>(
&self,
s: &S,
mode: AspectRatioMode
) -> SizeF<'_>
Returns a size scaled to a rectangle with the given width and height, according to the specified mode.
See also: [scale()
]
Overloads Returns a size scaled to a rectangle with the given size s, according to the specified mode.
sourcepub fn expanded_to<S: SizeFTrait<'a>>(&self, arg0: &S) -> SizeF<'_>
pub fn expanded_to<S: SizeFTrait<'a>>(&self, arg0: &S) -> SizeF<'_>
Returns a size holding the maximum width and height of this size and the given otherSize.
See also: [bounded_to()
]
[scale()
]
sourcepub fn bounded_to<S: SizeFTrait<'a>>(&self, arg0: &S) -> SizeF<'_>
pub fn bounded_to<S: SizeFTrait<'a>>(&self, arg0: &S) -> SizeF<'_>
Returns a size holding the minimum width and height of this size and the given otherSize.
See also: [expanded_to()
]
[scale()
]
sourcepub fn rwidth(&self) -> f32
pub fn rwidth(&self) -> f32
Returns a reference to the width.
Using a reference makes it possible to manipulate the width directly. For example:
See also: [rheight()
]
[set_width()
]
sourcepub fn rheight(&self) -> f32
pub fn rheight(&self) -> f32
Returns a reference to the height.
Using a reference makes it possible to manipulate the height directly. For example:
See also: [rwidth()
]
[set_height()
]
sourcepub fn to_size(&self) -> Size<'_>
pub fn to_size(&self) -> Size<'_>
Returns an integer based copy of this size.
Note that the coordinates in the returned size will be rounded to the nearest integer.
See also: [q_size_f()
]