The QSize 類使用整數點精度定義 2D 對象的大小。 更多...
| 頭: | #include <QSize> |
| QSize () | |
| QSize (int width , int height ) | |
| QSize | boundedTo (const QSize & otherSize ) const |
| QSize | expandedTo (const QSize & otherSize ) const |
| int | height () const |
| bool | isEmpty () const |
| bool | isNull () const |
| bool | isValid () const |
| int & | rheight () |
| int & | rwidth () |
| void | scale (int width , int height , Qt::AspectRatioMode mode ) |
| void | scale (const QSize & size , Qt::AspectRatioMode mode ) |
| void | setHeight (int height ) |
| void | setWidth (int width ) |
| void | transpose () |
| int | width () const |
| QSize & | operator*= (qreal factor ) |
| QSize & | operator+= (const QSize & size ) |
| QSize & | operator-= (const QSize & size ) |
| QSize & | operator/= (qreal divisor ) |
| bool | operator!= (const QSize & s1 , const QSize & s2 ) |
| const QSize | operator* (qreal factor , const QSize & size ) |
| const QSize | operator* (const QSize & size , qreal factor ) |
| const QSize | operator+ (const QSize & s1 , const QSize & s2 ) |
| const QSize | operator- (const QSize & s1 , const QSize & s2 ) |
| const QSize | operator/ (const QSize & size , qreal divisor ) |
| QDataStream & | operator<< (QDataStream & stream , const QSize & size ) |
| bool | operator== (const QSize & s1 , const QSize & s2 ) |
| QDataStream & | operator>> (QDataStream & stream , QSize & size ) |
The QSize 類使用整數點精度定義 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 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 () 函數以檢索尺寸保持的最大高度和寬度為 this 尺寸和給定尺寸。同樣, boundedTo () 函數返迴大小保持最小高度和寬度 this 尺寸和給定尺寸。
QSize 對象可以被流化及比較。
另請參閱 QSizeF , QPoint ,和 QRect .
采用無效寬度和高度構造尺寸 (即 isValid () returns false).
另請參閱 isValid ().
構造尺寸,采用給定 width and height .
另請參閱 setWidth () 和 setHeight ().
返迴尺寸,該尺寸保持最小寬度 高度,及給定 otherSize .
另請參閱 expandedTo () 和 scale ().
返迴的尺寸保持此尺寸的最大寬度 高度和給定 otherSize .
返迴高度。
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Returns true if both the width and height is 0; otherwise returns false.
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
返迴高度的引用。
使用引用使直接操縱高度成為可能。例如:
QSize size(100, 10); size.rheight() += 5; // size becomes (100,15)
另請參閱 rwidth () 和 setHeight ().
返迴寬度的引用。
使用引用使直接操縱寬度成為可能。例如:
QSize size(100, 10); size.rwidth() += 20; // size becomes (120,10)
另請參閱 rheight () 和 setWidth ().
把尺寸比例縮放到矩形采用給定 width and height ,根據指定 mode :
範例:
QSize t1(10, 12); t1.scale(60, 60, Qt::IgnoreAspectRatio); // t1 is (60, 60) QSize t2(10, 12); t2.scale(60, 60, Qt::KeepAspectRatio); // t2 is (50, 60) QSize t3(10, 12); t3.scale(60, 60, Qt::KeepAspectRatioByExpanding); // t3 is (60, 72)
另請參閱 setWidth () 和 setHeight ().
這是重載函數。
把尺寸比例縮放到矩形采用給定 size ,根據指定 mode .
將高度設為給定 height .
另請參閱 rheight (), height (),和 setWidth ().
將寬度設為給定 width .
另請參閱 rwidth (), width (),和 setHeight ().
交換寬度和高度值。
另請參閱 setWidth () 和 setHeight ().
返迴寬度。
這是重載函數。
寬度和高度兩者乘以給定 factor ,並返迴大小的引用。
注意,結果被四捨五入到最近整數。
另請參閱 scale ().
添加給定 size to this 尺寸,並返迴此大小的引用。例如:
QSize s( 3, 7); QSize r(-1, 4); s += r; // s becomes (2,11)
減去給定 size from this 尺寸,並返迴此大小的引用。例如:
QSize s( 3, 7); QSize r(-1, 4); s -= r; // s becomes (4,3)
這是重載函數。
寬度和高度兩者除以給定 divisor ,並返迴大小的引用。
注意,結果被四捨五入到最近整數。
另請參閱 QSize::scale ().
返迴 true 若 s1 and s2 are different; otherwise returns false.
這是重載函數。
乘以給定 size 通過給定 factor ,並返迴被捨入到最近整數的結果。
乘以給定 size 通過給定 factor ,並返迴被捨入到最近整數的結果。
另請參閱 QSize::scale ().
返迴和對於 s1 and s2 ;各分量分彆相加。
返迴 s2 減去 s1 ;分彆減去各分量。
這是重載函數。
除以給定 size 通過給定 divisor ,並返迴被捨入到最近整數的結果。
另請參閱 QSize::scale ().
寫入給定 size 到給定 stream ,並返迴流引用。
另請參閱 序列化 Qt 數據類型 .
返迴 true 若 s1 and s2 相等;否則返迴 false。
讀取大小從給定 stream 進給定 size ,並返迴流引用。
另請參閱 序列化 Qt 數據類型 .