QSizeF Class Reference [QtCore module]The QSizeF class defines the size of a two-dimensional object using floating point precision. More...
Methods- __init__ (self)
- __init__ (self, QSize sz)
- __init__ (self, float w, float h)
- __init__ (self, QSizeF other)
- QSizeF boundedTo (self, QSizeF otherSize)
- QSizeF expandedTo (self, QSizeF otherSize)
- float height (self)
- bool isEmpty (self)
- bool isNull (self)
- bool isValid (self)
- scale (self, QSizeF s, Qt.AspectRatioMode mode)
- scale (self, float w, float h, Qt.AspectRatioMode mode)
- setHeight (self, float h)
- setWidth (self, float w)
- QSize toSize (self)
- transpose (self)
- float width (self)
Special Methods- QSizeF __add__ (self, QSizeF s2)
- QSizeF __div__ (self, float c)
- bool __eq__ (self, QSizeF s2)
- QSizeF __iadd__ (self, QSizeF s)
- QSizeF __idiv__ (self, float c)
- QSizeF __imul__ (self, float c)
- QSizeF __isub__ (self, QSizeF s)
- QSizeF __mul__ (self, QSizeF s)
- QSizeF __mul__ (self, float c)
- bool __ne__ (self, QSizeF s2)
- int __nonzero__ (self)
- object __repr__ (self)
- QSizeF __sub__ (self, QSizeF s2)
Detailed DescriptionThis class can be pickled. The QSizeF class defines the size of a two-dimensional object using floating 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.
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, and QRectF.
Method DocumentationQSizeF.__init__ (self)Constructs an invalid size.
See also isValid().
QSizeF.__init__ (self, QSize sz)Constructs a size with floating point accuracy from the given size.
See also toSize().
QSizeF.__init__ (self, float w, float h)Constructs a size with the given width and height.
QSizeF.__init__ (self, QSizeF other)QSizeF QSizeF.boundedTo (self, QSizeF otherSize)Returns a size holding the minimum width and height of this size and the given otherSize.
See also expandedTo() and scale().
QSizeF QSizeF.expandedTo (self, QSizeF otherSize)Returns a size holding the maximum width and height of this size and the given otherSize.
See also boundedTo() and scale().
float QSizeF.height (self)Returns the height.
See also width() and setHeight().
bool QSizeF.isEmpty (self)Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
See also isNull() and isValid().
bool QSizeF.isNull (self)Returns true if both the width and height is 0; otherwise returns false.
See also isValid() and isEmpty().
bool QSizeF.isValid (self)Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
See also isNull() and isEmpty().
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:
QSizeF t1(10, 12);
t1.scale(60, 60, Qt.IgnoreAspectRatio);
QSizeF t2(10, 12);
t2.scale(60, 60, Qt.KeepAspectRatio);
QSizeF t3(10, 12);
t3.scale(60, 60, Qt.KeepAspectRatioByExpanding);
See also setWidth() and setHeight().
QSizeF.scale (self, float w, float h, Qt.AspectRatioMode mode)This is an overloaded member function, provided for convenience.
Scales the size to a rectangle with the given size, according to the specified mode.
QSizeF.setHeight (self, float h)Sets the height to the given height.
See also height(), rheight(), and setWidth().
QSizeF.setWidth (self, float w)Sets the width to the given width.
See also width(), rwidth(), and setHeight().
QSize QSizeF.toSize (self)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().
QSizeF.transpose (self)Swaps the width and height values.
See also setWidth() and setHeight().
float QSizeF.width (self)Returns the width.
See also height() and setWidth().
QSizeF QSizeF.__add__ (self, QSizeF s2)QSizeF QSizeF.__div__ (self, float c)bool QSizeF.__eq__ (self, QSizeF s2)QSizeF QSizeF.__iadd__ (self, QSizeF s)QSizeF QSizeF.__idiv__ (self, float c)QSizeF QSizeF.__imul__ (self, float c)QSizeF QSizeF.__isub__ (self, QSizeF s)QSizeF QSizeF.__mul__ (self, QSizeF s)QSizeF QSizeF.__mul__ (self, float c)bool QSizeF.__ne__ (self, QSizeF s2)int QSizeF.__nonzero__ (self)object QSizeF.__repr__ (self)QSizeF QSizeF.__sub__ (self, QSizeF s2)
|