<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qsize.cpp --> <title>QSize Class | Qt Core 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QSize</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#related-non-members">Related Non-Members</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QSize Class</h1> <!-- $$$QSize-brief --> <p>The <a href="qsize.html">QSize</a> class defines the size of a two-dimensional object using integer point precision. <a href="#details">More...</a></p> <!-- @@@QSize --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QSize></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul> <li><a href="qsize-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#QSize">QSize</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#QSize-1">QSize</a></b>(int <i>width</i>, int <i>height</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#boundedTo">boundedTo</a></b>(const QSize &<i>otherSize</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#expandedTo">expandedTo</a></b>(const QSize &<i>otherSize</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#height">height</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#isEmpty">isEmpty</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#isNull">isNull</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#isValid">isValid</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#rheight">rheight</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#rwidth">rwidth</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#scale">scale</a></b>(int <i>width</i>, int <i>height</i>, Qt::AspectRatioMode <i>mode</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#scale-1">scale</a></b>(const QSize &<i>size</i>, Qt::AspectRatioMode <i>mode</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#scaled">scaled</a></b>(int <i>width</i>, int <i>height</i>, Qt::AspectRatioMode <i>mode</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#scaled-1">scaled</a></b>(const QSize &<i>s</i>, Qt::AspectRatioMode <i>mode</i>) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#setHeight">setHeight</a></b>(int <i>height</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#setWidth">setWidth</a></b>(int <i>width</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> CGSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#toCGSize">toCGSize</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#transpose">transpose</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#transposed">transposed</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#width">width</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-2a-eq">operator*=</a></b>(qreal <i>factor</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-2b-eq">operator+=</a></b>(const QSize &<i>size</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator--eq">operator-=</a></b>(const QSize &<i>size</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-2f-eq">operator/=</a></b>(qreal <i>divisor</i>)</td></tr> </table></div> <a name="related-non-members"></a> <h2 id="related-non-members">Related Non-Members</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-not-eq">operator!=</a></b>(const QSize &<i>s1</i>, const QSize &<i>s2</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-2a">operator*</a></b>(const QSize &<i>size</i>, qreal <i>factor</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-2a-1">operator*</a></b>(qreal <i>factor</i>, const QSize &<i>size</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-2b">operator+</a></b>(const QSize &<i>s1</i>, const QSize &<i>s2</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-">operator-</a></b>(const QSize &<i>s1</i>, const QSize &<i>s2</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> const QSize </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-2f">operator/</a></b>(const QSize &<i>size</i>, qreal <i>divisor</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-lt-lt">operator<<</a></b>(QDataStream &<i>stream</i>, const QSize &<i>size</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-eq-eq">operator==</a></b>(const QSize &<i>s1</i>, const QSize &<i>s2</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QDataStream &</td><td class="memItemRight bottomAlign"><b><a href="qsize.html#operator-gt-gt">operator>></a></b>(QDataStream &<i>stream</i>, QSize &<i>size</i>)</td></tr> </table></div> <a name="details"></a> <!-- $$$QSize-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qsize.html">QSize</a> class defines the size of a two-dimensional object using integer point precision.</p> <p>A size is specified by a <a href="qsize.html#width">width</a>() and a <a href="qsize.html#height">height</a>(). It can be set in the constructor and changed using the <a href="qsize.html#setWidth">setWidth</a>(), <a href="qsize.html#setHeight">setHeight</a>(), or <a href="qsize.html#scale">scale</a>() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the <a href="qsize.html#rwidth">rwidth</a>() and <a href="qsize.html#rheight">rheight</a>() functions. Finally, the width and height can be swapped using the <a href="qsize.html#transpose">transpose</a>() function.</p> <p>The <a href="qsize.html#isValid">isValid</a>() function determines if a size is valid (a valid size has both width and height greater than or equal to zero). The <a href="qsize.html#isEmpty">isEmpty</a>() function returns <code>true</code> if either of the width and height is less than, or equal to, zero, while the <a href="qsize.html#isNull">isNull</a>() function returns <code>true</code> only if both the width and the height is zero.</p> <p>Use the <a href="qsize.html#expandedTo">expandedTo</a>() function to retrieve a size which holds the maximum height and width of <i>this</i> size and a given size. Similarly, the <a href="qsize.html#boundedTo">boundedTo</a>() function returns a size which holds the minimum height and width of <i>this</i> size and a given size.</p> <p><a href="qsize.html">QSize</a> objects can be streamed as well as compared.</p> </div> <p><b>See also </b><a href="qsizef.html">QSizeF</a>, <a href="qpoint.html">QPoint</a>, and <a href="qrect.html">QRect</a>.</p> <!-- @@@QSize --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QSize[overload1]$$$QSize --> <h3 class="fn" id="QSize"><a name="QSize"></a>QSize::<span class="name">QSize</span>()</h3> <p>Constructs a size with an invalid width and height (i.e., <a href="qsize.html#isValid">isValid</a>() returns <code>false</code>).</p> <p><b>See also </b><a href="qsize.html#isValid">isValid</a>().</p> <!-- @@@QSize --> <!-- $$$QSize$$$QSizeintint --> <h3 class="fn" id="QSize-1"><a name="QSize-1"></a>QSize::<span class="name">QSize</span>(<span class="type">int</span> <i>width</i>, <span class="type">int</span> <i>height</i>)</h3> <p>Constructs a size with the given <i>width</i> and <i>height</i>.</p> <p><b>See also </b><a href="qsize.html#setWidth">setWidth</a>() and <a href="qsize.html#setHeight">setHeight</a>().</p> <!-- @@@QSize --> <!-- $$$boundedTo[overload1]$$$boundedToconstQSize& --> <h3 class="fn" id="boundedTo"><a name="boundedTo"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> QSize::<span class="name">boundedTo</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>otherSize</i>) const</h3> <p>Returns a size holding the minimum width and height of this size and the given <i>otherSize</i>.</p> <p><b>See also </b><a href="qsize.html#expandedTo">expandedTo</a>() and <a href="qsize.html#scale">scale</a>().</p> <!-- @@@boundedTo --> <!-- $$$expandedTo[overload1]$$$expandedToconstQSize& --> <h3 class="fn" id="expandedTo"><a name="expandedTo"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> QSize::<span class="name">expandedTo</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>otherSize</i>) const</h3> <p>Returns a size holding the maximum width and height of this size and the given <i>otherSize</i>.</p> <p><b>See also </b><a href="qsize.html#boundedTo">boundedTo</a>() and <a href="qsize.html#scale">scale</a>().</p> <!-- @@@expandedTo --> <!-- $$$height[overload1]$$$height --> <h3 class="fn" id="height"><a name="height"></a><span class="type">int</span> QSize::<span class="name">height</span>() const</h3> <p>Returns the height.</p> <p><b>See also </b><a href="qsize.html#width">width</a>() and <a href="qsize.html#setHeight">setHeight</a>().</p> <!-- @@@height --> <!-- $$$isEmpty[overload1]$$$isEmpty --> <h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QSize::<span class="name">isEmpty</span>() const</h3> <p>Returns <code>true</code> if either of the width and height is less than or equal to 0; otherwise returns <code>false</code>.</p> <p><b>See also </b><a href="qsize.html#isNull">isNull</a>() and <a href="qsize.html#isValid">isValid</a>().</p> <!-- @@@isEmpty --> <!-- $$$isNull[overload1]$$$isNull --> <h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QSize::<span class="name">isNull</span>() const</h3> <p>Returns <code>true</code> if both the width and height is 0; otherwise returns false.</p> <p><b>See also </b><a href="qsize.html#isValid">isValid</a>() and <a href="qsize.html#isEmpty">isEmpty</a>().</p> <!-- @@@isNull --> <!-- $$$isValid[overload1]$$$isValid --> <h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QSize::<span class="name">isValid</span>() const</h3> <p>Returns <code>true</code> if both the width and height is equal to or greater than 0; otherwise returns <code>false</code>.</p> <p><b>See also </b><a href="qsize.html#isNull">isNull</a>() and <a href="qsize.html#isEmpty">isEmpty</a>().</p> <!-- @@@isValid --> <!-- $$$rheight[overload1]$$$rheight --> <h3 class="fn" id="rheight"><a name="rheight"></a><span class="type">int</span> &QSize::<span class="name">rheight</span>()</h3> <p>Returns a reference to the height.</p> <p>Using a reference makes it possible to manipulate the height directly. For example:</p> <pre class="cpp"> <span class="type"><a href="qsize.html#QSize">QSize</a></span> size(<span class="number">100</span><span class="operator">,</span> <span class="number">10</span>); size<span class="operator">.</span>rheight() <span class="operator">+</span><span class="operator">=</span> <span class="number">5</span>; <span class="comment">// size becomes (100,15)</span> </pre> <p><b>See also </b><a href="qsize.html#rwidth">rwidth</a>() and <a href="qsize.html#setHeight">setHeight</a>().</p> <!-- @@@rheight --> <!-- $$$rwidth[overload1]$$$rwidth --> <h3 class="fn" id="rwidth"><a name="rwidth"></a><span class="type">int</span> &QSize::<span class="name">rwidth</span>()</h3> <p>Returns a reference to the width.</p> <p>Using a reference makes it possible to manipulate the width directly. For example:</p> <pre class="cpp"> <span class="type"><a href="qsize.html#QSize">QSize</a></span> size(<span class="number">100</span><span class="operator">,</span> <span class="number">10</span>); size<span class="operator">.</span>rwidth() <span class="operator">+</span><span class="operator">=</span> <span class="number">20</span>; <span class="comment">// size becomes (120,10)</span> </pre> <p><b>See also </b><a href="qsize.html#rheight">rheight</a>() and <a href="qsize.html#setWidth">setWidth</a>().</p> <!-- @@@rwidth --> <!-- $$$scale[overload1]$$$scaleintintQt::AspectRatioMode --> <h3 class="fn" id="scale"><a name="scale"></a><span class="type">void</span> QSize::<span class="name">scale</span>(<span class="type">int</span> <i>width</i>, <span class="type">int</span> <i>height</i>, <span class="type"><a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a></span> <i>mode</i>)</h3> <p>Scales the size to a rectangle with the given <i>width</i> and <i>height</i>, according to the specified <i>mode</i>:</p> <ul> <li>If <i>mode</i> is <a href="qt.html#AspectRatioMode-enum">Qt::IgnoreAspectRatio</a>, the size is set to (<i>width</i>, <i>height</i>).</li> <li>If <i>mode</i> is <a href="qt.html#AspectRatioMode-enum">Qt::KeepAspectRatio</a>, the current size is scaled to a rectangle as large as possible inside (<i>width</i>, <i>height</i>), preserving the aspect ratio.</li> <li>If <i>mode</i> is <a href="qt.html#AspectRatioMode-enum">Qt::KeepAspectRatioByExpanding</a>, the current size is scaled to a rectangle as small as possible outside (<i>width</i>, <i>height</i>), preserving the aspect ratio.</li> </ul> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qsize.html#QSize">QSize</a></span> t1(<span class="number">10</span><span class="operator">,</span> <span class="number">12</span>); t1<span class="operator">.</span>scale(<span class="number">60</span><span class="operator">,</span> <span class="number">60</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>IgnoreAspectRatio); <span class="comment">// t1 is (60, 60)</span> <span class="type"><a href="qsize.html#QSize">QSize</a></span> t2(<span class="number">10</span><span class="operator">,</span> <span class="number">12</span>); t2<span class="operator">.</span>scale(<span class="number">60</span><span class="operator">,</span> <span class="number">60</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>KeepAspectRatio); <span class="comment">// t2 is (50, 60)</span> <span class="type"><a href="qsize.html#QSize">QSize</a></span> t3(<span class="number">10</span><span class="operator">,</span> <span class="number">12</span>); t3<span class="operator">.</span>scale(<span class="number">60</span><span class="operator">,</span> <span class="number">60</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>KeepAspectRatioByExpanding); <span class="comment">// t3 is (60, 72)</span> </pre> <p><b>See also </b><a href="qsize.html#setWidth">setWidth</a>(), <a href="qsize.html#setHeight">setHeight</a>(), and <a href="qsize.html#scaled">scaled</a>().</p> <!-- @@@scale --> <!-- $$$scale$$$scaleconstQSize&Qt::AspectRatioMode --> <h3 class="fn" id="scale-1"><a name="scale-1"></a><span class="type">void</span> QSize::<span class="name">scale</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>, <span class="type"><a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a></span> <i>mode</i>)</h3> <p>This is an overloaded function.</p> <p>Scales the size to a rectangle with the given <i>size</i>, according to the specified <i>mode</i>.</p> <!-- @@@scale --> <!-- $$$scaled[overload1]$$$scaledintintQt::AspectRatioMode --> <h3 class="fn" id="scaled"><a name="scaled"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> QSize::<span class="name">scaled</span>(<span class="type">int</span> <i>width</i>, <span class="type">int</span> <i>height</i>, <span class="type"><a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a></span> <i>mode</i>) const</h3> <p>Return a size scaled to a rectangle with the given <i>width</i> and <i>height</i>, according to the specified <i>mode</i>.</p> <p>This function was introduced in Qt 5.0.</p> <p><b>See also </b><a href="qsize.html#scale">scale</a>().</p> <!-- @@@scaled --> <!-- $$$scaled$$$scaledconstQSize&Qt::AspectRatioMode --> <h3 class="fn" id="scaled-1"><a name="scaled-1"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> QSize::<span class="name">scaled</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s</i>, <span class="type"><a href="qt.html#AspectRatioMode-enum">Qt::AspectRatioMode</a></span> <i>mode</i>) const</h3> <p>This is an overloaded function.</p> <p>Return a size scaled to a rectangle with the given size <i>s</i>, according to the specified <i>mode</i>.</p> <p>This function was introduced in Qt 5.0.</p> <!-- @@@scaled --> <!-- $$$setHeight[overload1]$$$setHeightint --> <h3 class="fn" id="setHeight"><a name="setHeight"></a><span class="type">void</span> QSize::<span class="name">setHeight</span>(<span class="type">int</span> <i>height</i>)</h3> <p>Sets the height to the given <i>height</i>.</p> <p><b>See also </b><a href="qsize.html#rheight">rheight</a>(), <a href="qsize.html#height">height</a>(), and <a href="qsize.html#setWidth">setWidth</a>().</p> <!-- @@@setHeight --> <!-- $$$setWidth[overload1]$$$setWidthint --> <h3 class="fn" id="setWidth"><a name="setWidth"></a><span class="type">void</span> QSize::<span class="name">setWidth</span>(<span class="type">int</span> <i>width</i>)</h3> <p>Sets the width to the given <i>width</i>.</p> <p><b>See also </b><a href="qsize.html#rwidth">rwidth</a>(), <a href="qsize.html#width">width</a>(), and <a href="qsize.html#setHeight">setHeight</a>().</p> <!-- @@@setWidth --> <!-- $$$toCGSize[overload1]$$$toCGSize --> <h3 class="fn" id="toCGSize"><a name="toCGSize"></a><span class="type">CGSize</span> QSize::<span class="name">toCGSize</span>() const</h3> <p>Creates a CGSize from a <a href="qsize.html">QSize</a>.</p> <p>This function was introduced in Qt 5.8.</p> <p><b>See also </b><a href="qsizef.html#fromCGSize">QSizeF::fromCGSize</a>().</p> <!-- @@@toCGSize --> <!-- $$$transpose[overload1]$$$transpose --> <h3 class="fn" id="transpose"><a name="transpose"></a><span class="type">void</span> QSize::<span class="name">transpose</span>()</h3> <p>Swaps the width and height values.</p> <p><b>See also </b><a href="qsize.html#setWidth">setWidth</a>(), <a href="qsize.html#setHeight">setHeight</a>(), and <a href="qsize.html#transposed">transposed</a>().</p> <!-- @@@transpose --> <!-- $$$transposed[overload1]$$$transposed --> <h3 class="fn" id="transposed"><a name="transposed"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> QSize::<span class="name">transposed</span>() const</h3> <p>Returns a <a href="qsize.html">QSize</a> with width and height swapped.</p> <p>This function was introduced in Qt 5.0.</p> <p><b>See also </b><a href="qsize.html#transpose">transpose</a>().</p> <!-- @@@transposed --> <!-- $$$width[overload1]$$$width --> <h3 class="fn" id="width"><a name="width"></a><span class="type">int</span> QSize::<span class="name">width</span>() const</h3> <p>Returns the width.</p> <p><b>See also </b><a href="qsize.html#height">height</a>() and <a href="qsize.html#setWidth">setWidth</a>().</p> <!-- @@@width --> <!-- $$$operator*=[overload1]$$$operator*=qreal --> <h3 class="fn" id="operator-2a-eq"><a name="operator-2a-eq"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> &QSize::<span class="name">operator*=</span>(<span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>factor</i>)</h3> <p>This is an overloaded function.</p> <p>Multiplies both the width and height by the given <i>factor</i>, and returns a reference to the size.</p> <p>Note that the result is rounded to the nearest integer.</p> <p><b>See also </b><a href="qsize.html#scale">scale</a>().</p> <!-- @@@operator*= --> <!-- $$$operator+=[overload1]$$$operator+=constQSize& --> <h3 class="fn" id="operator-2b-eq"><a name="operator-2b-eq"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> &QSize::<span class="name">operator+=</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>)</h3> <p>Adds the given <i>size</i> to <i>this</i> size, and returns a reference to this size. For example:</p> <pre class="cpp"> <span class="type"><a href="qsize.html#QSize">QSize</a></span> s( <span class="number">3</span><span class="operator">,</span> <span class="number">7</span>); <span class="type"><a href="qsize.html#QSize">QSize</a></span> r(<span class="operator">-</span><span class="number">1</span><span class="operator">,</span> <span class="number">4</span>); s <span class="operator">+</span><span class="operator">=</span> r; <span class="comment">// s becomes (2,11)</span> </pre> <!-- @@@operator+= --> <!-- $$$operator-=[overload1]$$$operator-=constQSize& --> <h3 class="fn" id="operator--eq"><a name="operator--eq"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> &QSize::<span class="name">operator-=</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>)</h3> <p>Subtracts the given <i>size</i> from <i>this</i> size, and returns a reference to this size. For example:</p> <pre class="cpp"> <span class="type"><a href="qsize.html#QSize">QSize</a></span> s( <span class="number">3</span><span class="operator">,</span> <span class="number">7</span>); <span class="type"><a href="qsize.html#QSize">QSize</a></span> r(<span class="operator">-</span><span class="number">1</span><span class="operator">,</span> <span class="number">4</span>); s <span class="operator">-</span><span class="operator">=</span> r; <span class="comment">// s becomes (4,3)</span> </pre> <!-- @@@operator-= --> <!-- $$$operator/=[overload1]$$$operator/=qreal --> <h3 class="fn" id="operator-2f-eq"><a name="operator-2f-eq"></a><span class="type"><a href="qsize.html#QSize">QSize</a></span> &QSize::<span class="name">operator/=</span>(<span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>divisor</i>)</h3> <p>This is an overloaded function.</p> <p>Divides both the width and height by the given <i>divisor</i>, and returns a reference to the size.</p> <p>Note that the result is rounded to the nearest integer.</p> <p><b>See also </b><a href="qsize.html#scale">QSize::scale</a>().</p> <!-- @@@operator/= --> </div> <div class="relnonmem"> <h2>Related Non-Members</h2> <!-- $$$operator!=[overload1]$$$operator!=constQSize&constQSize& --> <h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> <span class="name">operator!=</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s1</i>, const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s2</i>)</h3> <p>Returns <code>true</code> if <i>s1</i> and <i>s2</i> are different; otherwise returns <code>false</code>.</p> <!-- @@@operator!= --> <!-- $$$operator*[overload1]$$$operator*constQSize&qreal --> <h3 class="fn" id="operator-2a"><a name="operator-2a"></a>const <span class="type"><a href="qsize.html#QSize">QSize</a></span> <span class="name">operator*</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>factor</i>)</h3> <p>Multiplies the given <i>size</i> by the given <i>factor</i>, and returns the result rounded to the nearest integer.</p> <p><b>See also </b><a href="qsize.html#scale">QSize::scale</a>().</p> <!-- @@@operator* --> <!-- $$$operator*$$$operator*qrealconstQSize& --> <h3 class="fn" id="operator-2a-1"><a name="operator-2a-1"></a>const <span class="type"><a href="qsize.html#QSize">QSize</a></span> <span class="name">operator*</span>(<span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>factor</i>, const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>)</h3> <p>This is an overloaded function.</p> <p>Multiplies the given <i>size</i> by the given <i>factor</i>, and returns the result rounded to the nearest integer.</p> <!-- @@@operator* --> <!-- $$$operator+[overload1]$$$operator+constQSize&constQSize& --> <h3 class="fn" id="operator-2b"><a name="operator-2b"></a>const <span class="type"><a href="qsize.html#QSize">QSize</a></span> <span class="name">operator+</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s1</i>, const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s2</i>)</h3> <p>Returns the sum of <i>s1</i> and <i>s2</i>; each component is added separately.</p> <!-- @@@operator+ --> <!-- $$$operator-[overload1]$$$operator-constQSize&constQSize& --> <h3 class="fn" id="operator-"><a name="operator-"></a>const <span class="type"><a href="qsize.html#QSize">QSize</a></span> <span class="name">operator-</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s1</i>, const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s2</i>)</h3> <p>Returns <i>s2</i> subtracted from <i>s1</i>; each component is subtracted separately.</p> <!-- @@@operator- --> <!-- $$$operator/[overload1]$$$operator/constQSize&qreal --> <h3 class="fn" id="operator-2f"><a name="operator-2f"></a>const <span class="type"><a href="qsize.html#QSize">QSize</a></span> <span class="name">operator/</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>divisor</i>)</h3> <p>This is an overloaded function.</p> <p>Divides the given <i>size</i> by the given <i>divisor</i>, and returns the result rounded to the nearest integer.</p> <p><b>See also </b><a href="qsize.html#scale">QSize::scale</a>().</p> <!-- @@@operator/ --> <!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQSize& --> <h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &<span class="name">operator<<</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &<i>stream</i>, const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>)</h3> <p>Writes the given <i>size</i> to the given <i>stream</i>, and returns a reference to the stream.</p> <p><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p> <!-- @@@operator<< --> <!-- $$$operator==[overload1]$$$operator==constQSize&constQSize& --> <h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> <span class="name">operator==</span>(const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s1</i>, const <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>s2</i>)</h3> <p>Returns <code>true</code> if <i>s1</i> and <i>s2</i> are equal; otherwise returns <code>false</code>.</p> <!-- @@@operator== --> <!-- $$$operator>>[overload1]$$$operator>>QDataStream&QSize& --> <h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &<span class="name">operator>></span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &<i>stream</i>, <span class="type"><a href="qsize.html#QSize">QSize</a></span> &<i>size</i>)</h3> <p>Reads a size from the given <i>stream</i> into the given <i>size</i>, and returns a reference to the stream.</p> <p><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p> <!-- @@@operator>> --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>