QSizeF

The QSizeF class defines the size of a two-dimensional object using floating point precision. More

Inheritance diagram of PySide6.QtCore.QSizeF

Synopsis

Functions

Detailed Description

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.

See also

QSize QPointF QRectF

class PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF(sz)

PySide6.QtCore.QSizeF(QSizeF)

PySide6.QtCore.QSizeF(w, h)

Parameters

Constructs an invalid size.

See also

isValid()

Constructs a size with floating point accuracy from the given size.

See also

toSize()

Constructs a size with the given finite width and height.

PySide6.QtCore.QSizeF.__reduce__()
Return type

object

PySide6.QtCore.QSizeF.__repr__()
Return type

object

PySide6.QtCore.QSizeF.boundedTo(arg__1)
Parameters

arg__1PySide6.QtCore.QSizeF

Return type

PySide6.QtCore.QSizeF

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

PySide6.QtCore.QSizeF.expandedTo(arg__1)
Parameters

arg__1PySide6.QtCore.QSizeF

Return type

PySide6.QtCore.QSizeF

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

See also

boundedTo() scale()

PySide6.QtCore.QSizeF.grownBy(m)
Parameters

mPySide6.QtCore.QMarginsF

Return type

PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF.height()
Return type

float

Returns the height.

See also

width() setHeight()

PySide6.QtCore.QSizeF.isEmpty()
Return type

bool

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

See also

isNull() isValid()

PySide6.QtCore.QSizeF.isNull()
Return type

bool

Returns true if both the width and height are 0.0 (ignoring the sign); otherwise returns false.

See also

isValid() isEmpty()

PySide6.QtCore.QSizeF.isValid()
Return type

bool

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

See also

isNull() isEmpty()

PySide6.QtCore.QSizeF.__ne__(s2)
Parameters

s2PySide6.QtCore.QSizeF

Return type

bool

PySide6.QtCore.QSizeF.__mul__(c)
Parameters

c – float

Return type

PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF.__mul__(c)
Parameters

c – float

Return type

PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF.__imul__(c)
Parameters

c – float

Return type

PySide6.QtCore.QSizeF

This is an overloaded function.

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

See also

scale()

PySide6.QtCore.QSizeF.__add__(s2)
Parameters

s2PySide6.QtCore.QSizeF

Return type

PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF.__iadd__(arg__1)
Parameters

arg__1PySide6.QtCore.QSizeF

Return type

PySide6.QtCore.QSizeF

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

s = QSizeF( 3, 7)
r = QSizeF(-1, 4)
s += r
# s becomes (2,11)
PySide6.QtCore.QSizeF.__sub__(s2)
Parameters

s2PySide6.QtCore.QSizeF

Return type

PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF.__isub__(arg__1)
Parameters

arg__1PySide6.QtCore.QSizeF

Return type

PySide6.QtCore.QSizeF

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

s = QSizeF( 3, 7)
r = QSizeF(-1, 4)
s -= r
# s becomes (4,3)
PySide6.QtCore.QSizeF.__div__(c)
Parameters

c – float

Return type

PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF.__idiv__(c)
Parameters

c – float

Return type

PySide6.QtCore.QSizeF

This is an overloaded function.

Divides both the width and height by the given divisor and returns a reference to the size. The divisor must not be either zero or NaN.

See also

scale()

PySide6.QtCore.QSizeF.__eq__(s2)
Parameters

s2PySide6.QtCore.QSizeF

Return type

bool

PySide6.QtCore.QSizeF.scale(s, mode)
Parameters

This is an overloaded function.

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

PySide6.QtCore.QSizeF.scale(w, h, mode)
Parameters

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

  • If mode is IgnoreAspectRatio , the size is set to (width, height).

  • If mode is KeepAspectRatio , the current size is scaled to a rectangle as large as possible inside (width, height), preserving the aspect ratio.

  • If mode is KeepAspectRatioByExpanding , the current size is scaled to a rectangle as small as possible outside (width, height), preserving the aspect ratio.

Example:

t1 = QSizeF(10, 12)
t1.scale(60, 60, Qt.IgnoreAspectRatio)
# t1 is (60, 60)
t2 = QSizeF(10, 12)
t2.scale(60, 60, Qt.KeepAspectRatio)
# t2 is (50, 60)
t3 = QSizeF(10, 12)
t3.scale(60, 60, Qt.KeepAspectRatioByExpanding)
# t3 is (60, 72)
PySide6.QtCore.QSizeF.scaled(w, h, mode)
Parameters
Return type

PySide6.QtCore.QSizeF

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

See also

scale()

PySide6.QtCore.QSizeF.scaled(s, mode)
Parameters
Return type

PySide6.QtCore.QSizeF

This is an overloaded function.

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

PySide6.QtCore.QSizeF.setHeight(h)
Parameters

h – float

Sets the height to the given finite height.

See also

height() rheight() setWidth()

PySide6.QtCore.QSizeF.setWidth(w)
Parameters

w – float

Sets the width to the given finite width.

See also

width() rwidth() setHeight()

PySide6.QtCore.QSizeF.shrunkBy(m)
Parameters

mPySide6.QtCore.QMarginsF

Return type

PySide6.QtCore.QSizeF

PySide6.QtCore.QSizeF.toSize()
Return type

PySide6.QtCore.QSize

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

QSizeF()

PySide6.QtCore.QSizeF.toTuple()
Return type

object

PySide6.QtCore.QSizeF.transpose()

Swaps the width and height values.

PySide6.QtCore.QSizeF.transposed()
Return type

PySide6.QtCore.QSizeF

Returns the size with width and height values swapped.

See also

transpose()

PySide6.QtCore.QSizeF.width()
Return type

float

Returns the width.

See also

height() setWidth()