Qt 4.8
Public Functions | Properties | Friends | Related Functions | List of all members
QSizeF Class Reference

The QSizeF class defines the size of a two-dimensional object using floating point precision. More...

#include <qsize.h>

Public Functions

QSizeF boundedTo (const QSizeF &) const
 Returns a size holding the minimum width and height of this size and the given otherSize. More...
 
QSizeF expandedTo (const QSizeF &) const
 Returns a size holding the maximum width and height of this size and the given otherSize. More...
 
qreal height () const
 Returns the height. More...
 
bool isEmpty () const
 Returns true if either of the width and height is less than or equal to 0; otherwise returns false. More...
 
bool isNull () const
 Returns true if both the width and height are +0. More...
 
bool isValid () const
 Returns true if both the width and height is equal to or greater than 0; otherwise returns false. More...
 
QSizeFoperator*= (qreal c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies both the width and height by the given factor and returns a reference to the size. More...
 
QSizeFoperator+= (const QSizeF &)
 Adds the given size to this size and returns a reference to this size. More...
 
QSizeFoperator-= (const QSizeF &)
 Subtracts the given size from this size and returns a reference to this size. More...
 
QSizeFoperator/= (qreal c)
 Divides both the width and height by the given divisor and returns a reference to the size. More...
 
 QSizeF ()
 Constructs an invalid size. More...
 
 QSizeF (const QSize &sz)
 Constructs a size with floating point accuracy from the given size. More...
 
 QSizeF (qreal w, qreal h)
 Constructs a size with the given width and height. More...
 
qrealrheight ()
 Returns a reference to the height. More...
 
qrealrwidth ()
 Returns a reference to the width. More...
 
void scale (qreal w, qreal h, Qt::AspectRatioMode mode)
 Scales the size to a rectangle with the given width and height, according to the specified mode. More...
 
void scale (const QSizeF &s, Qt::AspectRatioMode mode)
 Scales the size to a rectangle with the given size, according to the specified mode. More...
 
void setHeight (qreal h)
 Sets the height to the given height. More...
 
void setWidth (qreal w)
 Sets the width to the given width. More...
 
QSize toSize () const
 Returns an integer based copy of this size. More...
 
void transpose ()
 Swaps the width and height values. More...
 
qreal width () const
 Returns the width. More...
 

Properties

qreal ht
 
qreal wd
 

Friends

bool operator!= (const QSizeF &, const QSizeF &)
 Returns true if s1 and s2 are different; otherwise returns false. More...
 
const QSizeF operator* (const QSizeF &, qreal)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
const QSizeF operator* (qreal, const QSizeF &)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
const QSizeF operator+ (const QSizeF &, const QSizeF &)
 Returns the sum of s1 and s2; each component is added separately. More...
 
const QSizeF operator- (const QSizeF &, const QSizeF &)
 Returns s2 subtracted from s1; each component is subtracted separately. More...
 
const QSizeF operator/ (const QSizeF &, qreal)
 Divides the given size by the given divisor and returns the result. More...
 
bool operator== (const QSizeF &, const QSizeF &)
 Returns true if s1 and s2 are equal; otherwise returns false. More...
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QSizeF &size)
 Writes the given size to the given stream and returns a reference to the stream. More...
 
QDataStreamoperator>> (QDataStream &stream, QSizeF &size)
 Reads a size from the given stream into the given size and returns a reference to the stream. More...
 

Detailed Description

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, QRectF

Definition at line 202 of file qsize.h.

Constructors and Destructors

◆ QSizeF() [1/3]

QSizeF::QSizeF ( )
inline

Constructs an invalid size.

See also
isValid()

Definition at line 264 of file qsize.h.

Referenced by boundedTo(), expandedTo(), operator*(), operator+(), operator-(), operator/(), and scale().

265 { wd = ht = -1.; }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ QSizeF() [2/3]

QSizeF::QSizeF ( const QSize size)
inline

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

See also
toSize()

Definition at line 267 of file qsize.h.

268  : wd(sz.width()), ht(sz.height())
269 {
270 }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ QSizeF() [3/3]

QSizeF::QSizeF ( qreal  w,
qreal  h 
)
inline

Constructs a size with the given width and height.

Definition at line 272 of file qsize.h.

273 { wd = w; ht = h; }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

Functions

◆ boundedTo()

QSizeF QSizeF::boundedTo ( const QSizeF otherSize) const
inline

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

See also
expandedTo(), scale()

Definition at line 350 of file qsize.h.

Referenced by QGridLayoutItem::geometryWithin(), QGraphicsLayoutItem::setGeometry(), QGraphicsWidget::setGeometry(), and QGraphicsView::sizeHint().

351 {
352  return QSizeF(qMin(wd,otherSize.wd), qMin(ht,otherSize.ht));
353 }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ expandedTo()

QSizeF QSizeF::expandedTo ( const QSizeF otherSize) const
inline

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

See also
boundedTo(), scale()

Definition at line 345 of file qsize.h.

Referenced by QGraphicsLayoutItem::setGeometry(), and QGraphicsWidget::setGeometry().

346 {
347  return QSizeF(qMax(wd,otherSize.wd), qMax(ht,otherSize.ht));
348 }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ height()

qreal QSizeF::height ( ) const
inline

Returns the height.

See also
width(), setHeight()

Definition at line 287 of file qsize.h.

Referenced by _q_boundGeometryToSizeConstraints(), QPageSetupWidget::_q_paperSizeChanged(), QGraphicsTextItemPrivate::_q_updateBoundingRect(), QDeclarativeLoaderPrivate::_q_updateSize(), QTextDocument::adjustSize(), QDeclarativePaintedItem::boundingRect(), boundSize(), QGridLayoutItem::box(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), closestAcceptableSize(), combineSize(), QGraphicsTextItemPrivate::controlOffset(), QDeclarativeRow::doPositioning(), QDeclarativeFlow::doPositioning(), QSvgText::draw(), QTextDocumentLayoutPrivate::drawBorder(), QItemDelegate::drawDisplay(), QTextDocumentLayoutPrivate::drawFrame(), QTextDocumentLayoutPrivate::drawListItem(), QTextDocumentLayout::dynamicPageCount(), QGridLayoutItem::effectiveMaxSize(), QGraphicsLayoutItemPrivate::effectiveSizeHints(), QGridLayoutEngine::ensureGeometries(), epsilonCompare(), expandSize(), QFixedSize::fromSizeF(), QDeclarativeCompiler::genLiteralAssignment(), QGridLayoutItem::geometryWithin(), QTextDocumentLayoutPrivate::layoutCell(), QTextDocumentLayoutPrivate::layoutFlow(), QTextDocumentLayoutPrivate::layoutFrame(), QTextDocumentLayoutPrivate::layoutTable(), QGraphicsLayoutItem::maximumHeight(), QGraphicsLayoutItem::minimumHeight(), minimumHeightForWidth(), operator<<(), QPdfBaseEnginePrivate::pageRect(), QtopiaPrintEngine::paperRect(), QPdfBaseEnginePrivate::paperRect(), QPdf::paperSize(), QPrinter::paperSize(), QGraphicsLayoutItem::preferredHeight(), QDeclarativeBasePositioner::prePositioning(), qDrawRoundedCorners(), QRectF::QRectF(), qSizeFTopaperSize(), QSvgIOHandler::read(), QTextDocumentLayout::resizeInlineObject(), QAbstractTextDocumentLayout::resizeInlineObject(), QDeclarativeViewPrivate::rootObjectSize(), QGraphicsWidget::setGeometry(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), QPrinter::setPaperSize(), QPageSetupWidget::setPrinter(), QWin32PrintEngine::setProperty(), QGraphicsLayoutItemPrivate::setSize(), QDeclarativeItem::setSize(), QRectF::setSize(), QGLShaderProgram::setUniformValue(), QDeclarativeSizeFValueType::setValue(), sizeForOrientation(), QLabelPrivate::sizeForWidth(), QGridLayoutEngine::sizeHint(), QGraphicsTextItemPrivate::textControl(), QItemDelegate::textRectangle(), QTest::toString(), and QPageSetupWidget::unitChanged().

288 { return ht; }
qreal ht
Definition: qsize.h:245

◆ isEmpty()

bool QSizeF::isEmpty ( ) const
inline

Returns true if either of the width and height is less than or equal to 0; otherwise returns false.

See also
isNull(), isValid()

Definition at line 278 of file qsize.h.

Referenced by QBlitterPaintEngine::fillRect(), and qDrawRoundedCorners().

279 { return wd <= 0. || ht <= 0.; }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ isNull()

bool QSizeF::isNull ( ) const
inline

Returns true if both the width and height are +0.

0; otherwise returns false.

Note
Since this function treats +0.0 and -0.0 differently, sizes with zero width and height where either or both values have a negative sign are not defined to be null sizes.
See also
isValid(), isEmpty()

Definition at line 275 of file qsize.h.

Referenced by QTextEdit::resizeEvent().

276 { return qIsNull(wd) && qIsNull(ht); }
static bool qIsNull(double d)
Definition: qglobal.h:2061
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ isValid()

bool QSizeF::isValid ( ) const
inline

Returns true if both the width and height is equal to or greater than 0; otherwise returns false.

See also
isNull(), isEmpty()

Definition at line 281 of file qsize.h.

Referenced by QGraphicsWidget::adjustSize(), QGridLayoutItem::effectiveMaxSize(), QGraphicsLayoutItem::effectiveSizeHint(), and QDeclarativeViewPrivate::updateSize().

282 { return wd >= 0. && ht >= 0.; }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator*=()

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies both the width and height by the given factor and returns a reference to the size.

See also
scale()

Definition at line 311 of file qsize.h.

312 { wd *= c; ht *= c; return *this; }
unsigned char c[8]
Definition: qnumeric_p.h:62
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator+=()

QSizeF & QSizeF::operator+= ( const QSizeF size)
inline

Adds the given 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)

Definition at line 305 of file qsize.h.

306 { wd += s.wd; ht += s.ht; return *this; }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator-=()

QSizeF & QSizeF::operator-= ( const QSizeF size)
inline

Subtracts the given 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)

Definition at line 308 of file qsize.h.

309 { wd -= s.wd; ht -= s.ht; return *this; }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator/=()

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

Divides both the width and height by the given divisor and returns a reference to the size.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
scale()

Definition at line 332 of file qsize.h.

333 {
335  wd = wd/c; ht = ht/c;
336  return *this;
337 }
unsigned char c[8]
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043

◆ rheight()

qreal & QSizeF::rheight ( )
inline

Returns a reference to the height.

Using a reference makes it possible to manipulate the height directly. For example:

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

Definition at line 302 of file qsize.h.

Referenced by QGraphicsLayoutItemPrivate::effectiveSizeHints(), QPainterPath::operator==(), QtopiaPrintEngine::paperRect(), and QGraphicsLayoutItemPrivate::setSizeComponent().

303 { return ht; }
qreal ht
Definition: qsize.h:245

◆ rwidth()

qreal & QSizeF::rwidth ( )
inline

Returns a reference to the width.

Using a reference makes it possible to manipulate the width directly. For example:

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

Definition at line 299 of file qsize.h.

Referenced by QGraphicsLayoutItemPrivate::effectiveSizeHints(), QPainterPath::operator==(), and QtopiaPrintEngine::paperRect().

300 { return wd; }
qreal wd
Definition: qsize.h:244

◆ scale() [1/2]

void QSizeF::scale ( qreal  width,
qreal  height,
Qt::AspectRatioMode  mode 
)
inline

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);
// t1 is (60, 60)
QSizeF t2(10, 12);
t2.scale(60, 60, Qt::KeepAspectRatio);
// t2 is (50, 60)
QSizeF t3(10, 12);
// t3 is (60, 72)
See also
setWidth(), setHeight()

Definition at line 296 of file qsize.h.

Referenced by QPagePreview::paintEvent().

297 { scale(QSizeF(w, h), mode); }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
void scale(qreal w, qreal h, Qt::AspectRatioMode mode)
Scales the size to a rectangle with the given width and height, according to the specified mode...
Definition: qsize.h:296

◆ scale() [2/2]

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

Scales the size to a rectangle with the given size, according to the specified mode.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 726 of file qsize.cpp.

727 {
728  if (mode == Qt::IgnoreAspectRatio || qIsNull(wd) || qIsNull(ht)) {
729  wd = s.wd;
730  ht = s.ht;
731  } else {
732  bool useHeight;
733  qreal rw = s.ht * wd / ht;
734 
735  if (mode == Qt::KeepAspectRatio) {
736  useHeight = (rw <= s.wd);
737  } else { // mode == Qt::KeepAspectRatioByExpanding
738  useHeight = (rw >= s.wd);
739  }
740 
741  if (useHeight) {
742  wd = rw;
743  ht = s.ht;
744  } else {
745  ht = s.wd * ht / wd;
746  wd = s.wd;
747  }
748  }
749 }
double qreal
Definition: qglobal.h:1193
static bool qIsNull(double d)
Definition: qglobal.h:2061
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ setHeight()

void QSizeF::setHeight ( qreal  height)
inline

◆ setWidth()

void QSizeF::setWidth ( qreal  width)
inline

◆ toSize()

QSize QSizeF::toSize ( ) const
inline

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

Definition at line 355 of file qsize.h.

Referenced by documentSize(), QVGPaintEngine::drawImage(), QPagePreview::paintEvent(), QMacPrintEnginePrivate::paperSize(), QWhatsThat::QWhatsThat(), QTextEditPrivate::relayoutDocument(), QGraphicsProxyWidget::resizeEvent(), QMacPrintEnginePrivate::setPaperSize(), QGraphicsView::sizeHint(), and QDeclarativeTextPrivate::textDocumentImage().

356 {
357  return QSize(qRound(wd), qRound(ht));
358 }
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ transpose()

void QSizeF::transpose ( )

Swaps the width and height values.

See also
setWidth(), setHeight()

Definition at line 686 of file qsize.cpp.

687 {
688  qreal tmp = wd;
689  wd = ht;
690  ht = tmp;
691 }
double qreal
Definition: qglobal.h:1193
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ width()

qreal QSizeF::width ( ) const
inline

Returns the width.

See also
height(), setWidth()

Definition at line 284 of file qsize.h.

Referenced by QPlainTextEditPrivate::_q_adjustScrollbars(), _q_boundGeometryToSizeConstraints(), QPageSetupWidget::_q_paperSizeChanged(), QDeclarativeLoaderPrivate::_q_updateSize(), QTextDocument::adjustSize(), QDeclarativePaintedItem::boundingRect(), boundSize(), QGridLayoutItem::box(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), closestAcceptableSize(), combineSize(), QDeclarativeColumn::doPositioning(), QDeclarativeRow::doPositioning(), QDeclarativeFlow::doPositioning(), QSvgText::draw(), QTextDocumentLayoutPrivate::drawBlock(), QItemDelegate::drawDisplay(), QTextDocumentLayoutPrivate::drawListItem(), QGridLayoutItem::effectiveMaxSize(), QGraphicsLayoutItemPrivate::effectiveSizeHints(), QGridLayoutEngine::ensureGeometries(), epsilonCompare(), expandSize(), QFixedSize::fromSizeF(), QDeclarativeCompiler::genLiteralAssignment(), QGridLayoutItem::geometryWithin(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFrame(), QGraphicsLayoutItem::maximumWidth(), minimumHeightForWidth(), QGraphicsLayoutItem::minimumWidth(), operator<<(), QPdfBaseEnginePrivate::pageRect(), QPlainTextEdit::paintEvent(), QtopiaPrintEngine::paperRect(), QPdfBaseEnginePrivate::paperRect(), QPdf::paperSize(), QPrinter::paperSize(), QGraphicsLayoutItem::preferredWidth(), QDeclarativeBasePositioner::prePositioning(), qDrawRoundedCorners(), QRectF::QRectF(), qSizeFTopaperSize(), QSvgIOHandler::read(), QTextDocumentLayout::resizeInlineObject(), QAbstractTextDocumentLayout::resizeInlineObject(), QDeclarativeViewPrivate::rootObjectSize(), QGraphicsWidget::setGeometry(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), QPrinter::setPaperSize(), QPageSetupWidget::setPrinter(), QWin32PrintEngine::setProperty(), QGraphicsLayoutItemPrivate::setSize(), QDeclarativeItem::setSize(), QRectF::setSize(), QTextBrowserPrivate::setSource(), QGLShaderProgram::setUniformValue(), QDeclarativeSizeFValueType::setValue(), sizeForOrientation(), QLabelPrivate::sizeForWidth(), QGridLayoutEngine::sizeHint(), QMacStyle::subControlRect(), QItemDelegate::textRectangle(), QTest::toString(), and QPageSetupWidget::unitChanged().

285 { return wd; }
qreal wd
Definition: qsize.h:244

Friends and Related Functions

◆ operator!=

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

Returns true if s1 and s2 are different; otherwise returns false.

Definition at line 317 of file qsize.h.

318 { return !qFuzzyCompare(s1.wd, s2.wd) || !qFuzzyCompare(s1.ht, s2.ht); }
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
Definition: qglobal.h:2030
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator* [1/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Multiplies the given size by the given factor and returns the result.

See also
QSizeF::scale()

Definition at line 326 of file qsize.h.

327 { return QSizeF(s.wd*c, s.ht*c); }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
unsigned char c[8]
Definition: qnumeric_p.h:62

◆ operator* [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Multiplies the given size by the given factor and returns the result.

Definition at line 329 of file qsize.h.

330 { return QSizeF(s.wd*c, s.ht*c); }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
unsigned char c[8]
Definition: qnumeric_p.h:62

◆ operator+

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

Returns the sum of s1 and s2; each component is added separately.

Definition at line 320 of file qsize.h.

321 { return QSizeF(s1.wd+s2.wd, s1.ht+s2.ht); }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator-

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

Returns s2 subtracted from s1; each component is subtracted separately.

Definition at line 323 of file qsize.h.

324 { return QSizeF(s1.wd-s2.wd, s1.ht-s2.ht); }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator/

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

Divides the given size by the given divisor and returns the result.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
QSizeF::scale()

Definition at line 339 of file qsize.h.

340 {
342  return QSizeF(s.wd/c, s.ht/c);
343 }
QSizeF()
Constructs an invalid size.
Definition: qsize.h:264
unsigned char c[8]
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043

◆ operator<<()

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

Writes the given size to the given stream and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 953 of file qsize.cpp.

Referenced by toSize().

954 {
955  s << double(sz.width()) << double(sz.height());
956  return s;
957 }

◆ operator==

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

Returns true if s1 and s2 are equal; otherwise returns false.

Definition at line 314 of file qsize.h.

315 { return qFuzzyCompare(s1.wd, s2.wd) && qFuzzyCompare(s1.ht, s2.ht); }
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
Definition: qglobal.h:2030
qreal wd
Definition: qsize.h:244
qreal ht
Definition: qsize.h:245

◆ operator>>()

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

Reads a size from the given stream into the given size and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 972 of file qsize.cpp.

973 {
974  double w, h;
975  s >> w;
976  s >> h;
977  sz.setWidth(qreal(w));
978  sz.setHeight(qreal(h));
979  return s;
980 }
double qreal
Definition: qglobal.h:1193

Properties

◆ ht

qreal QSizeF::ht
private

◆ wd

qreal QSizeF::wd
private

The documentation for this class was generated from the following files: