QSizeF 类使用浮点精度定义 2D 对象的大小。 更多...
头: | #include <QSizeF> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
QSizeF () | |
QSizeF (const QSize & size ) | |
QSizeF (qreal width , qreal height ) | |
QSizeF | boundedTo (const QSizeF & otherSize ) const |
QSizeF | expandedTo (const QSizeF & otherSize ) const |
QSizeF | grownBy (QMarginsF margins ) const |
qreal | height () const |
bool | isEmpty () const |
bool | isNull () const |
bool | isValid () const |
qreal & | rheight () |
qreal & | rwidth () |
void | scale (qreal width , qreal height , Qt::AspectRatioMode mode ) |
void | scale (const QSizeF & size , Qt::AspectRatioMode mode ) |
QSizeF | scaled (qreal width , qreal height , Qt::AspectRatioMode mode ) const |
QSizeF | scaled (const QSizeF & s , Qt::AspectRatioMode mode ) const |
void | setHeight (qreal height ) |
void | setWidth (qreal width ) |
QSizeF | shrunkBy (QMarginsF margins ) const |
CGSize | toCGSize () const |
QSize | toSize () const |
void | transpose () |
QSizeF | transposed () const |
qreal | width () const |
QSizeF & | operator*= (qreal factor ) |
QSizeF & | operator+= (const QSizeF & size ) |
QSizeF & | operator-= (const QSizeF & size ) |
QSizeF & | operator/= (qreal divisor ) |
QSizeF | fromCGSize (CGSize size ) |
bool | operator!= (const QSizeF & s1 , const QSizeF & s2 ) |
QSizeF | operator* (const QSizeF & size , qreal factor ) |
QSizeF | operator* (qreal factor , const QSizeF & size ) |
QSizeF | operator+ (const QSizeF & s1 , const QSizeF & s2 ) |
QSizeF | operator- (const QSizeF & s1 , const QSizeF & s2 ) |
QSizeF | operator/ (const QSizeF & size , qreal divisor ) |
QDataStream & | operator<< (QDataStream & stream , const QSizeF & size ) |
bool | operator== (const QSizeF & s1 , const QSizeF & s2 ) |
QDataStream & | operator>> (QDataStream & stream , QSizeF & size ) |
大小的指定是通过 width () 和 height ()。可以在构造函数中设置它和改变使用 setWidth (), setHeight (),或 scale () 函数,或使用算术运算符。也可以直接操纵尺寸通过检索宽度和高度的引用使用 rwidth () 和 rheight () 函数。最后,可以交换宽度和高度使用 transpose () 函数。
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
() 函数返回
true
if either of the width and height is
less
than (or equal to) zero, while the
isNull
() 函数返回
true
仅当宽度和高度两者为 0 时。
使用 expandedTo () function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo () 函数返回由此尺寸和给定尺寸保持的最小高度 宽度的尺寸。
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.
另请参阅 QSize , QPointF ,和 QRectF .
[constexpr noexcept]
QSizeF
QSizeF::
grownBy
(
QMarginsF
margins
) const
返回尺寸产生自此尺寸的增长按 margins .
另请参阅 shrunkBy ().
[constexpr noexcept]
QSizeF
QSizeF::
shrunkBy
(
QMarginsF
margins
) const
返回尺寸产生从此尺寸的收缩按 margins .
另请参阅 grownBy ().
[constexpr noexcept]
QSizeF::
QSizeF
()
Constructs an invalid size.
另请参阅 isValid ().
[constexpr noexcept]
QSizeF::
QSizeF
(const
QSize
&
size
)
Constructs a size with floating point accuracy from the given size .
另请参阅 toSize () 和 QSize::toSizeF ().
[constexpr noexcept]
QSizeF::
QSizeF
(
qreal
width
,
qreal
height
)
Constructs a size with the given finite width and height .
[constexpr noexcept]
QSizeF
QSizeF::
boundedTo
(const
QSizeF
&
otherSize
) const
返回尺寸,该尺寸保持最小宽度 高度,及给定 otherSize .
另请参阅 expandedTo () 和 scale ().
[constexpr noexcept]
QSizeF
QSizeF::
expandedTo
(const
QSizeF
&
otherSize
) const
返回的尺寸保持此尺寸的最大宽度 高度和给定 otherSize .
[static noexcept]
QSizeF
QSizeF::
fromCGSize
(
CGSize
size
)
创建 QRectF from size .
另请参阅 toCGSize ().
[constexpr noexcept]
qreal
QSizeF::
height
() const
返回高度。
[constexpr noexcept]
bool
QSizeF::
isEmpty
() const
返回
true
若宽度和高度两者任一 <= 0;否则返回
false
.
[noexcept]
bool
QSizeF::
isNull
() const
返回
true
若宽度和高度两者为 0.0 (忽略正负号);否则返回
false
.
[constexpr noexcept]
bool
QSizeF::
isValid
() const
返回
true
if both the width and height are equal to or greater than 0; otherwise returns
false
.
[constexpr noexcept]
qreal
&QSizeF::
rheight
()
返回高度的引用。
使用引用使直接操纵高度成为可能。例如:
QSizeF size(100, 10.2); size.rheight() += 5.5; // size becomes (100,15.7)
另请参阅 rwidth () 和 setHeight ().
[constexpr noexcept]
qreal
&QSizeF::
rwidth
()
返回宽度的引用。
使用引用使直接操纵宽度成为可能。例如:
QSizeF size(100.3, 10); size.rwidth() += 20.5; // size becomes (120.8,10)
另请参阅 rheight () 和 setWidth ().
[noexcept]
void
QSizeF::
scale
(
qreal
width
,
qreal
height
,
Qt::AspectRatioMode
mode
)
把尺寸比例缩放到矩形采用给定 width and height ,根据指定 mode .
范例:
QSizeF t1(10, 12); t1.scale(60, 60, Qt::IgnoreAspectRatio); // t1 is (60, 60) QSizeF t2(10, 12); t2.scale(60, 60, Qt::KeepAspectRatio); // t2 is (50, 60) QSizeF t3(10, 12); t3.scale(60, 60, Qt::KeepAspectRatioByExpanding); // t3 is (60, 72)
另请参阅 setWidth (), setHeight (),和 scaled ().
[noexcept]
void
QSizeF::
scale
(const
QSizeF
&
size
,
Qt::AspectRatioMode
mode
)
这是重载函数。
把尺寸比例缩放到矩形采用给定 size ,根据指定 mode .
[noexcept]
QSizeF
QSizeF::
scaled
(
qreal
width
,
qreal
height
,
Qt::AspectRatioMode
mode
) const
Returns a size scaled to a rectangle with the given width and height ,根据指定 mode .
另请参阅 scale ().
[noexcept]
QSizeF
QSizeF::
scaled
(const
QSizeF
&
s
,
Qt::AspectRatioMode
mode
) const
这是重载函数。
Returns a size scaled to a rectangle with the given size s ,根据指定 mode .
[constexpr noexcept]
void
QSizeF::
setHeight
(
qreal
height
)
Sets the height to the given finite height .
另请参阅 height (), rheight (),和 setWidth ().
[constexpr noexcept]
void
QSizeF::
setWidth
(
qreal
width
)
Sets the width to the given finite width .
另请参阅 width (), rwidth (),和 setHeight ().
[noexcept]
CGSize
QSizeF::
toCGSize
() const
创建 CGSize 从 QSizeF .
另请参阅 fromCGSize ().
[constexpr noexcept]
QSize
QSizeF::
toSize
() const
Returns an integer based copy of this size.
Note that the coordinates in the returned size will be rounded to the nearest integer.
另请参阅 QSizeF () 和 QSize::toSizeF ().
[noexcept]
void
QSizeF::
transpose
()
交换宽度和高度值。
另请参阅 setWidth (), setHeight (),和 transposed ().
[constexpr noexcept]
QSizeF
QSizeF::
transposed
() const
Returns the size with width and height values swapped.
另请参阅 transpose ().
[constexpr noexcept]
qreal
QSizeF::
width
() const
返回宽度。
[constexpr noexcept]
QSizeF
&QSizeF::
operator*=
(
qreal
factor
)
这是重载函数。
Multiplies both the width and height by the given finite factor and returns a reference to the size.
另请参阅 scale ().
[constexpr noexcept]
QSizeF
&QSizeF::
operator+=
(const
QSizeF
&
size
)
添加给定 size to this size and returns a reference to this size. For example:
QSizeF s( 3, 7); QSizeF r(-1, 4); s += r; // s becomes (2,11)
[constexpr noexcept]
QSizeF
&QSizeF::
operator-=
(const
QSizeF
&
size
)
减去给定 size from this size and returns a reference to this size. For example:
QSizeF s( 3, 7); QSizeF r(-1, 4); s -= r; // s becomes (4,3)
这是重载函数。
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.
另请参阅 scale ().
[constexpr]
bool
operator!=
(const
QSizeF
&
s1
, const
QSizeF
&
s2
)
返回
true
if
s1
and
s2
are sufficiently different; otherwise returns
false
.
警告: This function does not check for strict inequality; instead, it uses a fuzzy comparison to compare the sizes' extents.
[constexpr noexcept]
QSizeF
operator*
(const
QSizeF
&
size
,
qreal
factor
)
这是重载函数。
乘以给定 size by the given finite factor and returns the result.
另请参阅 QSizeF::scale ().
[constexpr noexcept]
QSizeF
operator*
(
qreal
factor
, const
QSizeF
&
size
)
这是重载函数。
乘以给定 size by the given finite factor and returns the result.
[constexpr noexcept]
QSizeF
operator+
(const
QSizeF
&
s1
, const
QSizeF
&
s2
)
Returns the sum of s1 and s2 ;分别相加各分量。
[constexpr noexcept]
QSizeF
operator-
(const
QSizeF
&
s1
, const
QSizeF
&
s2
)
返回 s2 减去 s1 ;分别减去各分量。
这是重载函数。
除以给定 size 通过给定 divisor and returns the result. The divisor must not be either zero or NaN.
另请参阅 QSizeF::scale ().
写入给定 size 到给定 stream 并返回流引用。
另请参阅 序列化 Qt 数据类型 .
[constexpr]
bool
operator==
(const
QSizeF
&
s1
, const
QSizeF
&
s2
)
返回
true
if
s1
and
s2
are approximately equal; otherwise returns false.
警告: This function does not check for strict equality; instead, it uses a fuzzy comparison to compare the sizes' extents.
另请参阅 qFuzzyCompare .
读取大小从给定 stream 进给定 size 并返回流引用。
另请参阅 序列化 Qt 数据类型 .