PySide6.QtCore.QSizeF¶
- class QSizeF¶
- The - QSizeFclass defines the size of a two-dimensional object using floating point precision. More…- Synopsis¶- Methods¶- def - __init__()
- def - __reduce__()
- def - __repr__()
- def - boundedTo()
- def - expandedTo()
- def - grownBy()
- def - height()
- def - isEmpty()
- def - isNull()
- def - isValid()
- def - __ne__()
- def - __mul__()
- def - __imul__()
- def - __add__()
- def - __iadd__()
- def - __sub__()
- def - __isub__()
- def - __div__()
- def - operator/=()
- def - __eq__()
- def - scale()
- def - scaled()
- def - setHeight()
- def - setWidth()
- def - shrunkBy()
- def - toSize()
- def - toTuple()
- def - transpose()
- def - transposed()
- def - width()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - 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- trueif either of the width and height is less than (or equal to) zero, while the- isNull()function returns- trueonly 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 - QSizeFclass also provides the- toSize()function returning a- QSizecopy of this size, constructed by rounding the width and height to the nearest integers.- QSizeFobjects can be streamed as well as compared.- __init__()¶
 - Constructs an invalid size. - See also - __init__(sz)
- Parameters:
- sz – - QSize
 
 - Constructs a size with floating point accuracy from the given - size.- __init__(w, h)
- Parameters:
- w – float 
- h – float 
 
 
 - Constructs a size with the given finite - widthand- height.- __reduce__()¶
- Return type:
- str 
 
 - __repr__()¶
- Return type:
- str 
 
 - Returns a size holding the minimum width and height of this size and the given - otherSize.- See also - Returns a size holding the maximum width and height of this size and the given - otherSize.- See also - height()¶
- Return type:
- float 
 
 - Returns the height. - See also - isEmpty()¶
- Return type:
- bool 
 
 - Returns - trueif either of the width and height is less than or equal to 0; otherwise returns- false.- isNull()¶
- Return type:
- bool 
 
 - Returns - trueif both the width and height are 0.0 (ignoring the sign); otherwise returns- false.- isValid()¶
- Return type:
- bool 
 
 - Returns - trueif both the width and height are equal to or greater than 0; otherwise returns- false.- __ne__(rhs)
- Parameters:
- rhs – - QSizeF
- Return type:
- bool 
 
 - Returns - trueif- lhsand- rhsare sufficiently different; otherwise returns- false.- Warning - This function does not check for strict inequality; instead, it uses a fuzzy comparison to compare the sizes’ extents. - This is an overloaded function. - Multiplies the given - sizeby the given finite- factorand returns the result.- __mul__(c)
- Parameters:
- c – float 
- Return type:
 
 - This is an overloaded function. - Multiplies the given - sizeby the given finite- factorand returns the result.- See also - This is an overloaded function. - Multiplies both the width and height by the given finite - factorand returns a reference to the size.- See also - Returns the sum of - s1and- s2; each component is added separately.- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Adds the given - sizeto 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) - Returns - s2subtracted from- s1; each component is subtracted separately.- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Subtracts the given - sizefrom 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) - This is an overloaded function. - Divides the given - sizeby the given- divisorand returns the result. The- divisormust not be either zero or NaN.- See also - operator/=(c)
- Parameters:
- c – float 
- Return type:
 
 - This is an overloaded function. - Divides both the width and height by the given - divisorand returns a reference to the size. The- divisormust not be either zero or NaN.- See also - __eq__(rhs)
- Parameters:
- rhs – - QSizeF
- Return type:
- bool 
 
 - Returns - trueif- lhsand- rhsare approximately equal; otherwise returns false.- Warning - This function does not check for strict equality; instead, it uses a fuzzy comparison to compare the sizes’ extents. - See also - qFuzzyCompare- scale(s, mode)¶
- Parameters:
- s – - QSizeF
- mode – - AspectRatioMode
 
 
 - This is an overloaded function. - Scales the size to a rectangle with the given - size, according to the specified- mode.- scale(w, h, mode)
- Parameters:
- w – float 
- h – float 
- mode – - AspectRatioMode
 
 
 - Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Scales the size to a rectangle with the given - widthand- height, according to the specified- mode.- If - modeis- IgnoreAspectRatio, the size is set to (- width,- height).
- If - modeis- KeepAspectRatio, the current size is scaled to a rectangle as large as possible inside (- width,- height), preserving the aspect ratio.
- If - modeis- 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) - See also - scaled(s, mode)¶
- Parameters:
- s – - QSizeF
- mode – - AspectRatioMode
 
- Return type:
 
 - This is an overloaded function. - Returns a size scaled to a rectangle with the given size - s, according to the specified- mode.- scaled(w, h, mode)
- Parameters:
- w – float 
- h – float 
- mode – - AspectRatioMode
 
- Return type:
 
 - Returns a size scaled to a rectangle with the given - widthand- height, according to the specified- mode.- See also - setHeight(h)¶
- Parameters:
- h – float 
 
 - Sets the height to the given finite - height.- See also - height()- rheight()- setWidth()- setWidth(w)¶
- Parameters:
- w – float 
 
 - Sets the width to the given finite - width.- See also - width()- rwidth()- setHeight()- 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()- toSizeF()- toTuple()¶
- Return type:
- object 
 
 - transpose()¶
 - Swaps the width and height values. - See also - Returns the size with width and height values swapped. - See also - width()¶
- Return type:
- float 
 
 - Returns the width. - See also