内容表

上一话题

QSignalTransition

下一话题

QSizeF

QSize

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

Inheritance diagram of PySide2.QtCore.QSize

概要

函数

详细描述

A size is specified by a width() height() . It can be set in the constructor and changed using the setWidth() , setHeight() ,或 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() 函数。

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.

使用 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.

class QSize

QSize(QSize)

QSize(w, h)

param w

int

param QSize

QSize

param h

int

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

另请参阅

isValid()

构造尺寸,采用给定 width and height .

PySide2.QtCore.QSize. __reduce__ ( )
返回类型

PyObject

PySide2.QtCore.QSize. __repr__ ( )
返回类型

PyObject

PySide2.QtCore.QSize. boundedTo ( arg__1 )
参数

arg__1 QSize

返回类型

QSize

返回尺寸,该尺寸保持最小宽度 高度,及给定 otherSize .

PySide2.QtCore.QSize. expandedTo ( arg__1 )
参数

arg__1 QSize

返回类型

QSize

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

PySide2.QtCore.QSize. grownBy ( m )
参数

m QMargins

返回类型

QSize

PySide2.QtCore.QSize. height ( )
返回类型

int

返回高度。

PySide2.QtCore.QSize. isEmpty ( )
返回类型

bool

返回 true 若宽度和高度两者任一 <= 0;否则返回 false .

PySide2.QtCore.QSize. isNull ( )
返回类型

bool

返回 true 若宽度和高度两者为 0;否则返回 false。

PySide2.QtCore.QSize. isValid ( )
返回类型

bool

返回 true 若宽度和高度两者 >= 0;否则返回 false .

PySide2.QtCore.QSize. __ne__ ( s2 )
参数

s2 QSize

返回类型

bool

PySide2.QtCore.QSize. __mul__ ( c )
参数

c qreal

返回类型

QSize

PySide2.QtCore.QSize. __mul__ ( c )
参数

c qreal

返回类型

QSize

PySide2.QtCore.QSize. __imul__ ( c )
参数

c qreal

返回类型

QSize

这是重载函数。

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.

另请参阅

scale()

PySide2.QtCore.QSize. __add__ ( s2 )
参数

s2 QSize

返回类型

QSize

PySide2.QtCore.QSize. __iadd__ ( arg__1 )
参数

arg__1 QSize

返回类型

QSize

添加给定 size to this size, and returns a reference to this size. For example:

s = QSize( 3, 7)
r = QSize(-1, 4)
s += r
# s becomes (2,11)
											
PySide2.QtCore.QSize. __sub__ ( s2 )
参数

s2 QSize

返回类型

QSize

PySide2.QtCore.QSize. __isub__ ( arg__1 )
参数

arg__1 QSize

返回类型

QSize

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

s = QSize( 3, 7)
r = QSize(-1, 4)
s -= r
# s becomes (4,3)
											
PySide2.QtCore.QSize. __div__ ( c )
参数

c qreal

返回类型

QSize

PySide2.QtCore.QSize. __idiv__ ( c )
参数

c qreal

返回类型

QSize

这是重载函数。

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.

另请参阅

scale()

PySide2.QtCore.QSize. __eq__ ( s2 )
参数

s2 QSize

返回类型

bool

PySide2.QtCore.QSize. scale ( s , mode )
参数
  • s QSize

  • mode AspectRatioMode

这是重载函数。

把尺寸比例缩放到矩形采用给定 size ,根据指定 mode .

PySide2.QtCore.QSize. scale ( w , h , mode )
参数
  • w int

  • h int

  • mode AspectRatioMode

把尺寸比例缩放到矩形采用给定 width and height ,根据指定 mode :

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

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

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

范例:

t1 = QSize(10, 12)
t1.scale(60, 60, Qt.IgnoreAspectRatio)
# t1 is (60, 60)
t2 = QSize(10, 12)
t2.scale(60, 60, Qt.KeepAspectRatio)
# t2 is (50, 60)
t3 = QSize(10, 12)
t3.scale(60, 60, Qt.KeepAspectRatioByExpanding)
# t3 is (60, 72)
											
PySide2.QtCore.QSize. scaled ( s , mode )
参数
  • s QSize

  • mode AspectRatioMode

返回类型

QSize

这是重载函数。

Return a size scaled to a rectangle with the given size s ,根据指定 mode .

PySide2.QtCore.QSize. scaled ( w , h , mode )
参数
  • w int

  • h int

  • mode AspectRatioMode

返回类型

QSize

Return a size scaled to a rectangle with the given width and height ,根据指定 mode .

另请参阅

scale()

PySide2.QtCore.QSize. setHeight ( h )
参数

h int

Sets the height to the given height .

另请参阅

rheight() height() setWidth()

PySide2.QtCore.QSize. setWidth ( w )
参数

w int

Sets the width to the given width .

另请参阅

rwidth() width() setHeight()

PySide2.QtCore.QSize. shrunkBy ( m )
参数

m QMargins

返回类型

QSize

PySide2.QtCore.QSize. toTuple ( )
返回类型

PyObject

PySide2.QtCore.QSize. transpose ( )

Swaps the width and height values.

PySide2.QtCore.QSize. transposed ( )
返回类型

QSize

返回 QSize with width and height swapped.

另请参阅

transpose()

PySide2.QtCore.QSize. width ( )
返回类型

int

返回宽度。