QSizeF 類

The QSizeF 類使用浮點精度定義 2D 對象的大小。 更多...

頭: #include <QSizeF>
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
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 )
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 )
const QSizeF operator* (const QSizeF & size , qreal factor )
const QSizeF operator* (qreal factor , const QSizeF & size )
const QSizeF operator+ (const QSizeF & s1 , const QSizeF & s2 )
const QSizeF operator- (const QSizeF & s1 , const QSizeF & s2 )
const 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 )

詳細描述

The QSizeF 類使用浮點精度定義 2D 對象的大小。

大小的指定是通過 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 類還提供 toSize () function returning a QSize copy of this size, constructed by rounding the width and height to the nearest integers.

QSizeF 對象可以被流化及比較。

另請參閱 QSize , QPointF ,和 QRectF .

成員函數文檔編製

QSizeF:: QSizeF ()

Constructs an invalid size.

另請參閱 isValid ().

QSizeF:: QSizeF (const QSize & size )

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

另請參閱 toSize ().

QSizeF:: QSizeF ( qreal width , qreal height )

構造尺寸,采用給定 width and height .

QSizeF QSizeF:: boundedTo (const QSizeF & otherSize ) const

返迴尺寸,該尺寸保持最小寬度 高度,及給定 otherSize .

另請參閱 expandedTo () 和 scale ().

QSizeF QSizeF:: expandedTo (const QSizeF & otherSize ) const

返迴的尺寸保持此尺寸的最大寬度 高度和給定 otherSize .

另請參閱 boundedTo () 和 scale ().

[static] QSizeF QSizeF:: fromCGSize ( CGSize size )

創建 QRectF from size .

該函數在 Qt 5.8 引入。

另請參閱 toCGSize ().

qreal QSizeF:: height () const

返迴高度。

另請參閱 width () 和 setHeight ().

bool QSizeF:: isEmpty () const

返迴 true 若寬度和高度兩者任一 <= 0;否則返迴 false .

另請參閱 isNull () 和 isValid ().

bool QSizeF:: isNull () const

返迴 true 若寬度和高度兩者為 0.0 (忽略正負號);否則返迴 false .

另請參閱 isValid () 和 isEmpty ().

bool QSizeF:: isValid () const

返迴 true 若寬度和高度兩者 >= 0;否則返迴 false .

另請參閱 isNull () 和 isEmpty ().

qreal &QSizeF:: rheight ()

返迴高度的引用。

使用引用使直接操縱高度成為可能。例如:

QSizeF size(100, 10.2);
size.rheight() += 5.5;
// size becomes (100,15.7)
					

另請參閱 rwidth () 和 setHeight ().

qreal &QSizeF:: rwidth ()

返迴寬度的引用。

使用引用使直接操縱寬度成為可能。例如:

QSizeF size(100.3, 10);
size.rwidth() += 20.5;
 // size becomes (120.8,10)
					

另請參閱 rheight () 和 setWidth ().

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 ().

void QSizeF:: scale (const QSizeF & size , Qt::AspectRatioMode mode )

這是重載函數。

把尺寸比例縮放到矩形采用給定 size ,根據指定 mode .

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 .

該函數在 Qt 5.0 引入。

另請參閱 scale ().

QSizeF QSizeF:: scaled (const QSizeF & s , Qt::AspectRatioMode mode ) const

這是重載函數。

Returns a size scaled to a rectangle with the given size s ,根據指定 mode .

該函數在 Qt 5.0 引入。

void QSizeF:: setHeight ( qreal height )

將高度設為給定 height .

另請參閱 height (), rheight (),和 setWidth ().

void QSizeF:: setWidth ( qreal width )

將寬度設為給定 width .

另請參閱 width (), rwidth (),和 setHeight ().

CGSize QSizeF:: toCGSize () const

創建 CGSize 從 QSizeF .

該函數在 Qt 5.8 引入。

另請參閱 fromCGSize ().

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 ().

void QSizeF:: transpose ()

交換寬度和高度值。

另請參閱 setWidth (), setHeight (),和 transposed ().

QSizeF QSizeF:: transposed () const

Returns the size with width and height values swapped.

該函數在 Qt 5.0 引入。

另請參閱 transpose ().

qreal QSizeF:: width () const

返迴寬度。

另請參閱 height () 和 setWidth ().

QSizeF &QSizeF:: operator*= ( qreal factor )

這是重載函數。

寬度和高度兩者乘以給定 factor and returns a reference to the size.

另請參閱 scale ().

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)
					

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)
					

QSizeF &QSizeF:: operator/= ( qreal divisor )

這是重載函數。

寬度和高度兩者除以給定 divisor and returns a reference to the size.

另請參閱 scale ().

相關非成員

bool operator!= (const QSizeF & s1 , const QSizeF & s2 )

返迴 true if s1 and s2 不同;否則返迴 false .

const QSizeF operator* (const QSizeF & size , qreal factor )

這是重載函數。

乘以給定 size 通過給定 factor and returns the result.

另請參閱 QSizeF::scale ().

const QSizeF operator* ( qreal factor , const QSizeF & size )

這是重載函數。

乘以給定 size 通過給定 factor and returns the result.

const QSizeF operator+ (const QSizeF & s1 , const QSizeF & s2 )

返迴和對於 s1 and s2 ;各分量分彆相加。

const QSizeF operator- (const QSizeF & s1 , const QSizeF & s2 )

返迴 s2 減去 s1 ;分彆減去各分量。

const QSizeF operator/ (const QSizeF & size , qreal divisor )

這是重載函數。

除以給定 size 通過給定 divisor and returns the result.

另請參閱 QSizeF::scale ().

QDataStream & operator<< ( QDataStream & stream , const QSizeF & size )

寫入給定 size 到給定 stream 並返迴流引用。

另請參閱 序列化 Qt 數據類型 .

bool operator== (const QSizeF & s1 , const QSizeF & s2 )

返迴 true if s1 and s2 相等;否則返迴 false。

QDataStream & operator>> ( QDataStream & stream , QSizeF & size )

讀取大小從給定 stream 進給定 size 並返迴流引用。

另請參閱 序列化 Qt 數據類型 .