Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 1355

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmatrix.cpp -->
  <title>QMatrix Class | Qt GUI 5.9</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.9</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QMatrix</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</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>
<li class="level2"><a href="#rendering-graphics">Rendering Graphics</a></li>
<li class="level2"><a href="#basic-matrix-operations">Basic Matrix Operations</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QMatrix Class</h1>
<!-- $$$QMatrix-brief -->
<p>The <a href="qmatrix.html">QMatrix</a> class specifies 2D transformations of a coordinate system. <a href="#details">More...</a></p>
<!-- @@@QMatrix -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QMatrix&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr></table></div><p><b>This class is obsolete.</b> It is provided to keep old source code working. We strongly advise against using it in new code.</p>
<ul>
<li><a href="qmatrix-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="qmatrix.html#QMatrix">QMatrix</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#QMatrix-2">QMatrix</a></b>(qreal <i>m11</i>, qreal <i>m12</i>, qreal <i>m21</i>, qreal <i>m22</i>, qreal <i>dx</i>, qreal <i>dy</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#QMatrix-3">QMatrix</a></b>(QMatrix &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#QMatrix-4">QMatrix</a></b>(const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#m11">m11</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#m12">m12</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#m21">m21</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#m22">m22</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#determinant">determinant</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#dx">dx</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#dy">dy</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#inverted">inverted</a></b>(bool *<i>invertible</i> = Q_NULLPTR) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#isIdentity">isIdentity</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#isInvertible">isInvertible</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map">map</a></b>(qreal <i>x</i>, qreal <i>y</i>, qreal *<i>tx</i>, qreal *<i>ty</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-1">map</a></b>(int <i>x</i>, int <i>y</i>, int *<i>tx</i>, int *<i>ty</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-2">map</a></b>(const QPoint &amp;<i>point</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-3">map</a></b>(const QPointF &amp;<i>point</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLine </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-4">map</a></b>(const QLine &amp;<i>line</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLineF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-5">map</a></b>(const QLineF &amp;<i>line</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygonF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-6">map</a></b>(const QPolygonF &amp;<i>polygon</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-7">map</a></b>(const QPolygon &amp;<i>polygon</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRegion </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-8">map</a></b>(const QRegion &amp;<i>region</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPainterPath </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-9">map</a></b>(const QPainterPath &amp;<i>path</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRectF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#mapRect">mapRect</a></b>(const QRectF &amp;<i>rectangle</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#mapRect-1">mapRect</a></b>(const QRect &amp;<i>rectangle</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#mapToPolygon">mapToPolygon</a></b>(const QRect &amp;<i>rectangle</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#reset">reset</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#rotate">rotate</a></b>(qreal <i>degrees</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#scale">scale</a></b>(qreal <i>sx</i>, qreal <i>sy</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#setMatrix">setMatrix</a></b>(qreal <i>m11</i>, qreal <i>m12</i>, qreal <i>m21</i>, qreal <i>m22</i>, qreal <i>dx</i>, qreal <i>dy</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#shear">shear</a></b>(qreal <i>sh</i>, qreal <i>sv</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#translate">translate</a></b>(qreal <i>dx</i>, qreal <i>dy</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-QVariant">operator QVariant</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-not-eq">operator!=</a></b>(const QMatrix &amp;<i>matrix</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a">operator*</a></b>(const QMatrix &amp;<i>matrix</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-eq">operator*=</a></b>(const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-eq">operator=</a></b>(QMatrix &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMatrix &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-eq-1">operator=</a></b>(const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-eq-eq">operator==</a></b>(const QMatrix &amp;<i>matrix</i>) const</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="qmatrix.html#qFuzzyCompare">qFuzzyCompare</a></b>(const QMatrix &amp;<i>m1</i>, const QMatrix &amp;<i>m2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#qHash">qHash</a></b>(const QMatrix &amp;<i>key</i>, uint <i>seed</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-1">operator*</a></b>(const QPoint &amp;<i>point</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-2">operator*</a></b>(const QPointF &amp;<i>point</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLineF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-3">operator*</a></b>(const QLineF &amp;<i>line</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLine </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-4">operator*</a></b>(const QLine &amp;<i>line</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygonF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-5">operator*</a></b>(const QPolygonF &amp;<i>polygon</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-6">operator*</a></b>(const QPolygon &amp;<i>polygon</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRegion </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-7">operator*</a></b>(const QRegion &amp;<i>region</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPainterPath </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-8">operator*</a></b>(const QPainterPath &amp;<i>path</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-lt-lt">operator&lt;&lt;</a></b>(QDataStream &amp;<i>stream</i>, const QMatrix &amp;<i>matrix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>stream</i>, QMatrix &amp;<i>matrix</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QMatrix-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qmatrix.html">QMatrix</a> class specifies 2D transformations of a coordinate system.</p>
<p>A matrix specifies how to translate, scale, shear or rotate the coordinate system, and is typically used when rendering graphics. <a href="qmatrix.html">QMatrix</a>, in contrast to <a href="qtransform.html">QTransform</a>, does not allow perspective transformations. <a href="qtransform.html">QTransform</a> is the recommended transformation class in Qt.</p>
<p>A <a href="qmatrix.html">QMatrix</a> object can be built using the <a href="qmatrix.html#setMatrix">setMatrix</a>(), <a href="qmatrix.html#scale">scale</a>(), <a href="qmatrix.html#rotate">rotate</a>(), <a href="qmatrix.html#translate">translate</a>() and <a href="qmatrix.html#shear">shear</a>() functions. Alternatively, it can be built by applying <a href="qmatrix.html#basic-matrix-operations">basic matrix operations</a>. The matrix can also be defined when constructed, and it can be reset to the identity matrix (the default) using the <a href="qmatrix.html#reset">reset</a>() function.</p>
<p>The <a href="qmatrix.html">QMatrix</a> class supports mapping of graphic primitives: A given point, line, polygon, region, or painter path can be mapped to the coordinate system defined by <i>this</i> matrix using the <a href="qmatrix.html#map">map</a>() function. In case of a rectangle, its coordinates can be transformed using the <a href="qmatrix.html#mapRect">mapRect</a>() function. A rectangle can also be transformed into a <i>polygon</i> (mapped to the coordinate system defined by <i>this</i> matrix), using the <a href="qmatrix.html#mapToPolygon">mapToPolygon</a>() function.</p>
<p><a href="qmatrix.html">QMatrix</a> provides the <a href="qmatrix.html#isIdentity">isIdentity</a>() function which returns <code>true</code> if the matrix is the identity matrix, and the <a href="qmatrix.html#isInvertible">isInvertible</a>() function which returns <code>true</code> if the matrix is non-singular (i.e&#x2e; AB = BA = I). The <a href="qmatrix.html#inverted">inverted</a>() function returns an inverted copy of <i>this</i> matrix if it is invertible (otherwise it returns the identity matrix). In addition, <a href="qmatrix.html">QMatrix</a> provides the <a href="qmatrix.html#determinant">determinant</a>() function returning the matrix's determinant.</p>
<p>Finally, the <a href="qmatrix.html">QMatrix</a> class supports matrix multiplication, and objects of the class can be streamed as well as compared.</p>
<a name="rendering-graphics"></a>
<h3 >Rendering Graphics</h3>
<p>When rendering graphics, the matrix defines the transformations but the actual transformation is performed by the drawing routines in <a href="qpainter.html">QPainter</a>.</p>
<p>By default, <a href="qpainter.html">QPainter</a> operates on the associated device's own coordinate system. The standard coordinate system of a <a href="qpaintdevice.html">QPaintDevice</a> has its origin located at the top-left position. The <i>x</i> values increase to the right; <i>y</i> values increase downward. For a complete description, see the <a href="coordsys.html">coordinate system</a> documentation.</p>
<p><a href="qpainter.html">QPainter</a> has functions to translate, scale, shear and rotate the coordinate system without using a <a href="qmatrix.html">QMatrix</a>. For example:</p>
<div class="table"><table class="generic" width="100%">
 <tr valign="top" class="odd"><td ><img src="images/qmatrix-simpletransformation.png" alt="" /></td><td ><pre class="cpp">

  <span class="type">void</span> SimpleTransformation<span class="operator">::</span>paintEvent(<span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>)
  {
      <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>);
      painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type">Qt</span><span class="operator">::</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>DashLine));
      painter<span class="operator">.</span>drawRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span>);

      painter<span class="operator">.</span>rotate(<span class="number">45</span>);

      painter<span class="operator">.</span>setFont(<span class="type"><a href="qfont.html">QFont</a></span>(<span class="string">&quot;Helvetica&quot;</span><span class="operator">,</span> <span class="number">24</span>));
      painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type">Qt</span><span class="operator">::</span>black<span class="operator">,</span> <span class="number">1</span>));
      painter<span class="operator">.</span>drawText(<span class="number">20</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="string">&quot;QMatrix&quot;</span>);
  }

</pre>
</td></tr>
</table></div>
<p>Although these functions are very convenient, it can be more efficient to build a <a href="qmatrix.html">QMatrix</a> and call <a href="qpainter-obsolete.html#setMatrix">QPainter::setMatrix</a>() if you want to perform more than a single transform operation. For example:</p>
<div class="table"><table class="generic" width="100%">
 <tr valign="top" class="odd"><td ><img src="images/qmatrix-combinedtransformation.png" alt="" /></td><td ><pre class="cpp">

  <span class="type">void</span> CombinedTransformation<span class="operator">::</span>paintEvent(<span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>)
  {
      <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>);
      painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type">Qt</span><span class="operator">::</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>DashLine));
      painter<span class="operator">.</span>drawRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span>);

      <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> matrix;
      matrix<span class="operator">.</span>translate(<span class="number">50</span><span class="operator">,</span> <span class="number">50</span>);
      matrix<span class="operator">.</span>rotate(<span class="number">45</span>);
      matrix<span class="operator">.</span>scale(<span class="number">0.5</span><span class="operator">,</span> <span class="number">1.0</span>);
      painter<span class="operator">.</span>setMatrix(matrix);

      painter<span class="operator">.</span>setFont(<span class="type"><a href="qfont.html">QFont</a></span>(<span class="string">&quot;Helvetica&quot;</span><span class="operator">,</span> <span class="number">24</span>));
      painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type">Qt</span><span class="operator">::</span>black<span class="operator">,</span> <span class="number">1</span>));
      painter<span class="operator">.</span>drawText(<span class="number">20</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="string">&quot;QMatrix&quot;</span>);
  }

</pre>
</td></tr>
</table></div>
<a name="basic-matrix-operations"></a>
<h3 >Basic Matrix Operations</h3>
<p class="centerAlign"><img src="images/qmatrix-representation.png" alt="" /></p><p>A <a href="qmatrix.html">QMatrix</a> object contains a 3 x 3 matrix. The <code>dx</code> and <code>dy</code> elements specify horizontal and vertical translation. The <code>m11</code> and <code>m22</code> elements specify horizontal and vertical scaling. And finally, the <code>m21</code> and <code>m12</code> elements specify horizontal and vertical <i>shearing</i>.</p>
<p><a href="qmatrix.html">QMatrix</a> transforms a point in the plane to another point using the following formulas:</p>
<pre class="cpp">

  x<span class="char">' = m11*x + m21*y + dx
  y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy

</pre>
<p>The point <i>(x, y)</i> is the original point, and <i>(x', y')</i> is the transformed point. <i>(x', y')</i> can be transformed back to <i>(x, y)</i> by performing the same operation on the <a href="qmatrix.html#inverted">inverted</a>() matrix.</p>
<p>The various matrix elements can be set when constructing the matrix, or by using the <a href="qmatrix.html#setMatrix">setMatrix</a>() function later on. They can also be manipulated using the <a href="qmatrix.html#translate">translate</a>(), <a href="qmatrix.html#rotate">rotate</a>(), <a href="qmatrix.html#scale">scale</a>() and <a href="qmatrix.html#shear">shear</a>() convenience functions, The currently set values can be retrieved using the <a href="qmatrix.html#m11">m11</a>(), <a href="qmatrix.html#m12">m12</a>(), <a href="qmatrix.html#m21">m21</a>(), <a href="qmatrix.html#m22">m22</a>(), <a href="qmatrix.html#dx">dx</a>() and <a href="qmatrix.html#dy">dy</a>() functions.</p>
<p>Translation is the simplest transformation. Setting <code>dx</code> and <code>dy</code> will move the coordinate system <code>dx</code> units along the X axis and <code>dy</code> units along the Y axis. Scaling can be done by setting <code>m11</code> and <code>m22</code>. For example, setting <code>m11</code> to 2 and <code>m22</code> to 1.5 will double the height and increase the width by 50%. The identity matrix has <code>m11</code> and <code>m22</code> set to 1 (all others are set to 0) mapping a point to itself. Shearing is controlled by <code>m12</code> and <code>m21</code>. Setting these elements to values different from zero will twist the coordinate system. Rotation is achieved by carefully setting both the shearing factors and the scaling factors.</p>
<p>Here's the combined transformations example using basic matrix operations:</p>
<div class="table"><table class="generic" width="100%">
 <tr valign="top" class="odd"><td ><img src="images/qmatrix-combinedtransformation.png" alt="" /></td><td ><pre class="cpp">

  <span class="type">void</span> BasicOperations<span class="operator">::</span>paintEvent(<span class="type"><a href="qpaintevent.html">QPaintEvent</a></span> <span class="operator">*</span>)
  {
      <span class="type">double</span> pi <span class="operator">=</span> <span class="number">3.14</span>;

      <span class="type">double</span> a    <span class="operator">=</span> pi<span class="operator">/</span><span class="number">180</span> <span class="operator">*</span> <span class="number">45.0</span>;
      <span class="type">double</span> sina <span class="operator">=</span> sin(a);
      <span class="type">double</span> cosa <span class="operator">=</span> cos(a);

      <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> translationMatrix(<span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">50.0</span><span class="operator">,</span> <span class="number">50.0</span>);
      <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> rotationMatrix(cosa<span class="operator">,</span> sina<span class="operator">,</span> <span class="operator">-</span>sina<span class="operator">,</span> cosa<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
      <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> scalingMatrix(<span class="number">0.5</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1.0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);

      <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> matrix;
      matrix <span class="operator">=</span>  scalingMatrix <span class="operator">*</span> rotationMatrix <span class="operator">*</span> translationMatrix;

      <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>);
      painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type">Qt</span><span class="operator">::</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>DashLine));
      painter<span class="operator">.</span>drawRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span>);

      painter<span class="operator">.</span>setMatrix(matrix);

      painter<span class="operator">.</span>setFont(<span class="type"><a href="qfont.html">QFont</a></span>(<span class="string">&quot;Helvetica&quot;</span><span class="operator">,</span> <span class="number">24</span>));
      painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type">Qt</span><span class="operator">::</span>black<span class="operator">,</span> <span class="number">1</span>));
      painter<span class="operator">.</span>drawText(<span class="number">20</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="string">&quot;QMatrix&quot;</span>);
  }

</pre>
</td></tr>
</table></div>
</div>
<p><b>See also </b><a href="qpainter.html">QPainter</a>, <a href="qtransform.html">QTransform</a>, <a href="coordsys.html">Coordinate System</a>, <a href="../qtwidgets/qtwidgets-painting-affine-example.html">Affine Transformations Example</a>, and <a href="../qtwidgets/qtwidgets-painting-transformations-example.html">Transformations Example</a>.</p>
<!-- @@@QMatrix -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QMatrix[overload1]$$$QMatrix -->
<h3 class="fn" id="QMatrix"><a name="QMatrix"></a>QMatrix::<span class="name">QMatrix</span>()</h3>
<p>Constructs an identity matrix.</p>
<p>All elements are set to zero except <code>m11</code> and <code>m22</code> (specifying the scale), which are set to 1.</p>
<p><b>See also </b><a href="qmatrix.html#reset">reset</a>().</p>
<!-- @@@QMatrix -->
<!-- $$$QMatrix$$$QMatrixqrealqrealqrealqrealqrealqreal -->
<h3 class="fn" id="QMatrix-2"><a name="QMatrix-2"></a>QMatrix::<span class="name">QMatrix</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m11</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m12</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m21</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m22</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>dx</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>dy</i>)</h3>
<p>Constructs a matrix with the elements, <i>m11</i>, <i>m12</i>, <i>m21</i>, <i>m22</i>, <i>dx</i> and <i>dy</i>.</p>
<p><b>See also </b><a href="qmatrix.html#setMatrix">setMatrix</a>().</p>
<!-- @@@QMatrix -->
<!-- $$$QMatrix$$$QMatrixQMatrix&& -->
<h3 class="fn" id="QMatrix-3"><a name="QMatrix-3"></a>QMatrix::<span class="name">QMatrix</span>(<span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-copy constructor.</p><!-- @@@QMatrix -->
<!-- $$$QMatrix$$$QMatrixconstQMatrix& -->
<h3 class="fn" id="QMatrix-4"><a name="QMatrix-4"></a>QMatrix::<span class="name">QMatrix</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>Constructs a matrix that is a copy of the given <i>matrix</i>.</p>
<!-- @@@QMatrix -->
<!-- $$$m11[overload1]$$$m11 -->
<h3 class="fn" id="m11"><a name="m11"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QMatrix::<span class="name">m11</span>() const</h3>
<p>Returns the horizontal scaling factor.</p>
<p><b>See also </b><a href="qmatrix.html#scale">scale</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@m11 -->
<!-- $$$m12[overload1]$$$m12 -->
<h3 class="fn" id="m12"><a name="m12"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QMatrix::<span class="name">m12</span>() const</h3>
<p>Returns the vertical shearing factor.</p>
<p><b>See also </b><a href="qmatrix.html#shear">shear</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@m12 -->
<!-- $$$m21[overload1]$$$m21 -->
<h3 class="fn" id="m21"><a name="m21"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QMatrix::<span class="name">m21</span>() const</h3>
<p>Returns the horizontal shearing factor.</p>
<p><b>See also </b><a href="qmatrix.html#shear">shear</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@m21 -->
<!-- $$$m22[overload1]$$$m22 -->
<h3 class="fn" id="m22"><a name="m22"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QMatrix::<span class="name">m22</span>() const</h3>
<p>Returns the vertical scaling factor.</p>
<p><b>See also </b><a href="qmatrix.html#scale">scale</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@m22 -->
<!-- $$$determinant[overload1]$$$determinant -->
<h3 class="fn" id="determinant"><a name="determinant"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QMatrix::<span class="name">determinant</span>() const</h3>
<p>Returns the matrix's determinant.</p>
<p>This function was introduced in  Qt 4.6.</p>
<!-- @@@determinant -->
<!-- $$$dx[overload1]$$$dx -->
<h3 class="fn" id="dx"><a name="dx"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QMatrix::<span class="name">dx</span>() const</h3>
<p>Returns the horizontal translation factor.</p>
<p><b>See also </b><a href="qmatrix.html#translate">translate</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@dx -->
<!-- $$$dy[overload1]$$$dy -->
<h3 class="fn" id="dy"><a name="dy"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QMatrix::<span class="name">dy</span>() const</h3>
<p>Returns the vertical translation factor.</p>
<p><b>See also </b><a href="qmatrix.html#translate">translate</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@dy -->
<!-- $$$inverted[overload1]$$$invertedbool* -->
<h3 class="fn" id="inverted"><a name="inverted"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> QMatrix::<span class="name">inverted</span>(<span class="type">bool</span> *<i>invertible</i> = Q_NULLPTR) const</h3>
<p>Returns an inverted copy of this matrix.</p>
<p>If the matrix is singular (not invertible), the returned matrix is the identity matrix. If <i>invertible</i> is valid (i.e&#x2e; not 0), its value is set to true if the matrix is invertible, otherwise it is set to false.</p>
<p><b>See also </b><a href="qmatrix.html#isInvertible">isInvertible</a>().</p>
<!-- @@@inverted -->
<!-- $$$isIdentity[overload1]$$$isIdentity -->
<h3 class="fn" id="isIdentity"><a name="isIdentity"></a><span class="type">bool</span> QMatrix::<span class="name">isIdentity</span>() const</h3>
<p>Returns <code>true</code> if the matrix is the identity matrix, otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qmatrix.html#reset">reset</a>().</p>
<!-- @@@isIdentity -->
<!-- $$$isInvertible[overload1]$$$isInvertible -->
<h3 class="fn" id="isInvertible"><a name="isInvertible"></a><span class="type">bool</span> QMatrix::<span class="name">isInvertible</span>() const</h3>
<p>Returns <code>true</code> if the matrix is invertible, otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qmatrix.html#inverted">inverted</a>().</p>
<!-- @@@isInvertible -->
<!-- $$$map[overload1]$$$mapqrealqrealqreal*qreal* -->
<h3 class="fn" id="map"><a name="map"></a><span class="type">void</span> QMatrix::<span class="name">map</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>x</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>y</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> *<i>tx</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> *<i>ty</i>) const</h3>
<p>Maps the given coordinates <i>x</i> and <i>y</i> into the coordinate system defined by this matrix. The resulting values are put in *<i>tx</i> and *<i>ty</i>, respectively.</p>
<p>The coordinates are transformed using the following formulas:</p>
<pre class="cpp">

  x<span class="char">' = m11*x + m21*y + dx
  y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy

</pre>
<p>The point (x, y) is the original point, and (x', y') is the transformed point.</p>
<p><b>See also </b><a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@map -->
<!-- $$$map$$$mapintintint*int* -->
<h3 class="fn" id="map-1"><a name="map-1"></a><span class="type">void</span> QMatrix::<span class="name">map</span>(<span class="type">int</span> <i>x</i>, <span class="type">int</span> <i>y</i>, <span class="type">int</span> *<i>tx</i>, <span class="type">int</span> *<i>ty</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Maps the given coordinates <i>x</i> and <i>y</i> into the coordinate system defined by this matrix. The resulting values are put in *<i>tx</i> and *<i>ty</i>, respectively. Note that the transformed coordinates are rounded to the nearest integer.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQPoint& -->
<h3 class="fn" id="map-2"><a name="map-2"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>point</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="../qtcore/qpoint.html">QPoint</a> object that is a copy of the given <i>point</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQPointF& -->
<h3 class="fn" id="map-3"><a name="map-3"></a><span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;<i>point</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="../qtcore/qpointf.html">QPointF</a> object that is a copy of the given <i>point</i>, mapped into the coordinate system defined by this matrix.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQLine& -->
<h3 class="fn" id="map-4"><a name="map-4"></a><span class="type"><a href="../qtcore/qline.html">QLine</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="../qtcore/qline.html">QLine</a></span> &amp;<i>line</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="../qtcore/qline.html">QLine</a> object that is a copy of the given <i>line</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQLineF& -->
<h3 class="fn" id="map-5"><a name="map-5"></a><span class="type"><a href="../qtcore/qlinef.html">QLineF</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="../qtcore/qlinef.html">QLineF</a></span> &amp;<i>line</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="../qtcore/qlinef.html">QLineF</a> object that is a copy of the given <i>line</i>, mapped into the coordinate system defined by this matrix.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQPolygonF& -->
<h3 class="fn" id="map-6"><a name="map-6"></a><span class="type"><a href="qpolygonf.html">QPolygonF</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="qpolygonf.html">QPolygonF</a></span> &amp;<i>polygon</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="qpolygonf.html">QPolygonF</a> object that is a copy of the given <i>polygon</i>, mapped into the coordinate system defined by this matrix.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQPolygon& -->
<h3 class="fn" id="map-7"><a name="map-7"></a><span class="type"><a href="qpolygon.html">QPolygon</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="qpolygon.html">QPolygon</a></span> &amp;<i>polygon</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="qpolygon.html">QPolygon</a> object that is a copy of the given <i>polygon</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQRegion& -->
<h3 class="fn" id="map-8"><a name="map-8"></a><span class="type"><a href="qregion.html">QRegion</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="qregion.html">QRegion</a></span> &amp;<i>region</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="qregion.html">QRegion</a> object that is a copy of the given <i>region</i>, mapped into the coordinate system defined by this matrix.</p>
<p>Calling this method can be rather expensive if rotations or shearing are used.</p>
<!-- @@@map -->
<!-- $$$map$$$mapconstQPainterPath& -->
<h3 class="fn" id="map-9"><a name="map-9"></a><span class="type"><a href="qpainterpath.html">QPainterPath</a></span> QMatrix::<span class="name">map</span>(const <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> &amp;<i>path</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="qpainterpath.html">QPainterPath</a> object that is a copy of the given <i>path</i>, mapped into the coordinate system defined by this matrix.</p>
<!-- @@@map -->
<!-- $$$mapRect[overload1]$$$mapRectconstQRectF& -->
<h3 class="fn" id="mapRect"><a name="mapRect"></a><span class="type"><a href="../qtcore/qrectf.html">QRectF</a></span> QMatrix::<span class="name">mapRect</span>(const <span class="type"><a href="../qtcore/qrectf.html">QRectF</a></span> &amp;<i>rectangle</i>) const</h3>
<p>Creates and returns a <a href="../qtcore/qrectf.html">QRectF</a> object that is a copy of the given <i>rectangle</i>, mapped into the coordinate system defined by this matrix.</p>
<p>The rectangle's coordinates are transformed using the following formulas:</p>
<pre class="cpp">

  x<span class="char">' = m11*x + m21*y + dx
  y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy

</pre>
<p>If rotation or shearing has been specified, this function returns the <i>bounding</i> rectangle. To retrieve the exact region the given <i>rectangle</i> maps to, use the <a href="qmatrix.html#mapToPolygon">mapToPolygon</a>() function instead.</p>
<p><b>See also </b><a href="qmatrix.html#mapToPolygon">mapToPolygon</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@mapRect -->
<!-- $$$mapRect$$$mapRectconstQRect& -->
<h3 class="fn" id="mapRect-1"><a name="mapRect-1"></a><span class="type"><a href="../qtcore/qrect.html">QRect</a></span> QMatrix::<span class="name">mapRect</span>(const <span class="type"><a href="../qtcore/qrect.html">QRect</a></span> &amp;<i>rectangle</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Creates and returns a <a href="../qtcore/qrect.html">QRect</a> object that is a copy of the given <i>rectangle</i>, mapped into the coordinate system defined by this matrix. Note that the transformed coordinates are rounded to the nearest integer.</p>
<!-- @@@mapRect -->
<!-- $$$mapToPolygon[overload1]$$$mapToPolygonconstQRect& -->
<h3 class="fn" id="mapToPolygon"><a name="mapToPolygon"></a><span class="type"><a href="qpolygon.html">QPolygon</a></span> QMatrix::<span class="name">mapToPolygon</span>(const <span class="type"><a href="../qtcore/qrect.html">QRect</a></span> &amp;<i>rectangle</i>) const</h3>
<p>Creates and returns a <a href="qpolygon.html">QPolygon</a> representation of the given <i>rectangle</i>, mapped into the coordinate system defined by this matrix.</p>
<p>The rectangle's coordinates are transformed using the following formulas:</p>
<pre class="cpp">

  x<span class="char">' = m11*x + m21*y + dx
  y'</span> <span class="operator">=</span> m22<span class="operator">*</span>y <span class="operator">+</span> m12<span class="operator">*</span>x <span class="operator">+</span> dy

</pre>
<p>Polygons and rectangles behave slightly differently when transformed (due to integer rounding), so <code>matrix.map(QPolygon(rectangle))</code> is not always the same as <code>matrix.mapToPolygon(rectangle)</code>.</p>
<p><b>See also </b><a href="qmatrix.html#mapRect">mapRect</a>() and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@mapToPolygon -->
<!-- $$$reset[overload1]$$$reset -->
<h3 class="fn" id="reset"><a name="reset"></a><span class="type">void</span> QMatrix::<span class="name">reset</span>()</h3>
<p>Resets the matrix to an identity matrix, i.e&#x2e; all elements are set to zero, except <code>m11</code> and <code>m22</code> (specifying the scale) which are set to 1.</p>
<p><b>See also </b><a href="qmatrix.html#QMatrix">QMatrix</a>(), <a href="qmatrix.html#isIdentity">isIdentity</a>(), and <a href="qmatrix.html#basic-matrix-operations">Basic Matrix Operations</a>.</p>
<!-- @@@reset -->
<!-- $$$rotate[overload1]$$$rotateqreal -->
<h3 class="fn" id="rotate"><a name="rotate"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;QMatrix::<span class="name">rotate</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>degrees</i>)</h3>
<p>Rotates the coordinate system the given <i>degrees</i> counterclockwise.</p>
<p>Note that if you apply a <a href="qmatrix.html" class="obsolete">QMatrix</a> to a point defined in widget coordinates, the direction of the rotation will be clockwise because the y-axis points downwards.</p>
<p>Returns a reference to the matrix.</p>
<p><b>See also </b><a href="qmatrix.html#setMatrix">setMatrix</a>().</p>
<!-- @@@rotate -->
<!-- $$$scale[overload1]$$$scaleqrealqreal -->
<h3 class="fn" id="scale"><a name="scale"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;QMatrix::<span class="name">scale</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>sx</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>sy</i>)</h3>
<p>Scales the coordinate system by <i>sx</i> horizontally and <i>sy</i> vertically, and returns a reference to the matrix.</p>
<p><b>See also </b><a href="qmatrix.html#setMatrix">setMatrix</a>().</p>
<!-- @@@scale -->
<!-- $$$setMatrix[overload1]$$$setMatrixqrealqrealqrealqrealqrealqreal -->
<h3 class="fn" id="setMatrix"><a name="setMatrix"></a><span class="type">void</span> QMatrix::<span class="name">setMatrix</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m11</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m12</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m21</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>m22</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>dx</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>dy</i>)</h3>
<p>Sets the matrix elements to the specified values, <i>m11</i>, <i>m12</i>, <i>m21</i>, <i>m22</i>, <i>dx</i> and <i>dy</i>.</p>
<p>Note that this function replaces the previous values. <a href="qmatrix.html" class="obsolete">QMatrix</a> provide the <a href="qmatrix.html#translate">translate</a>(), <a href="qmatrix.html#rotate">rotate</a>(), <a href="qmatrix.html#scale">scale</a>() and <a href="qmatrix.html#shear">shear</a>() convenience functions to manipulate the various matrix elements based on the currently defined coordinate system.</p>
<p><b>See also </b><a href="qmatrix.html#QMatrix">QMatrix</a>().</p>
<!-- @@@setMatrix -->
<!-- $$$shear[overload1]$$$shearqrealqreal -->
<h3 class="fn" id="shear"><a name="shear"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;QMatrix::<span class="name">shear</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>sh</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>sv</i>)</h3>
<p>Shears the coordinate system by <i>sh</i> horizontally and <i>sv</i> vertically, and returns a reference to the matrix.</p>
<p><b>See also </b><a href="qmatrix.html#setMatrix">setMatrix</a>().</p>
<!-- @@@shear -->
<!-- $$$translate[overload1]$$$translateqrealqreal -->
<h3 class="fn" id="translate"><a name="translate"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;QMatrix::<span class="name">translate</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>dx</i>, <span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>dy</i>)</h3>
<p>Moves the coordinate system <i>dx</i> along the x axis and <i>dy</i> along the y axis, and returns a reference to the matrix.</p>
<p><b>See also </b><a href="qmatrix.html#setMatrix">setMatrix</a>().</p>
<!-- @@@translate -->
<!-- $$$operator QVariant[overload1]$$$operator QVariant -->
<h3 class="fn" id="operator-QVariant"><a name="operator-QVariant"></a>QMatrix::<span class="name">operator QVariant</span>() const</h3>
<p>Returns the matrix as a <a href="../qtcore/qvariant.html">QVariant</a>.</p>
<p>This function was introduced in  Qt 4.2.</p>
<!-- @@@operator QVariant -->
<!-- $$$operator!=[overload1]$$$operator!=constQMatrix& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QMatrix::<span class="name">operator!=</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>) const</h3>
<p>Returns <code>true</code> if this matrix is not equal to the given <i>matrix</i>, otherwise returns <code>false</code>.</p>
<!-- @@@operator!= -->
<!-- $$$operator*[overload1]$$$operator*constQMatrix& -->
<h3 class="fn" id="operator-2a"><a name="operator-2a"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> QMatrix::<span class="name">operator*</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>) const</h3>
<p>Returns the result of multiplying this matrix by the given <i>matrix</i>.</p>
<p>Note that matrix multiplication is not commutative, i.e&#x2e; a*b != b*a.</p>
<!-- @@@operator* -->
<!-- $$$operator*=[overload1]$$$operator*=constQMatrix& -->
<h3 class="fn" id="operator-2a-eq"><a name="operator-2a-eq"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;QMatrix::<span class="name">operator*=</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is an overloaded function.</p>
<p>Returns the result of multiplying this matrix by the given <i>matrix</i>.</p>
<!-- @@@operator*= -->
<!-- $$$operator=[overload1]$$$operator=QMatrix&& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;QMatrix::<span class="name">operator=</span>(<span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-assignment operator.</p><!-- @@@operator= -->
<!-- $$$operator=$$$operator=constQMatrix& -->
<h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;QMatrix::<span class="name">operator=</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>Assigns the given <i>matrix</i>'s values to this matrix.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQMatrix& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QMatrix::<span class="name">operator==</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>) const</h3>
<p>Returns <code>true</code> if this matrix is equal to the given <i>matrix</i>, otherwise returns <code>false</code>.</p>
<!-- @@@operator== -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qFuzzyCompare[overload1]$$$qFuzzyCompareconstQMatrix&constQMatrix& -->
<h3 class="fn" id="qFuzzyCompare"><a name="qFuzzyCompare"></a><span class="type">bool</span> <span class="name">qFuzzyCompare</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>m1</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>m2</i>)</h3>
<p>The <a href="qmatrix4x4.html#qFuzzyCompare">qFuzzyCompare</a> function is for comparing two matrices using a fuzziness factor.</p>
<p>Returns <code>true</code> if <i>m1</i> and <i>m2</i> are equal, allowing for a small fuzziness factor for floating-point comparisons; false otherwise.</p>
<p>This function was introduced in  Qt 4.6.</p>
<!-- @@@qFuzzyCompare -->
<!-- $$$qHash[overload1]$$$qHashconstQMatrix&uint -->
<h3 class="fn" id="qHash"><a name="qHash"></a><span class="type"><a href="../qtcore/qtglobal.html#uint-typedef">uint</a></span> <span class="name">qHash</span>(const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>key</i>, <span class="type"><a href="../qtcore/qtglobal.html#uint-typedef">uint</a></span> <i>seed</i> = 0)</h3>
<p>Returns the hash value for <i>key</i>, using <i>seed</i> to seed the calculation.</p>
<p>This function was introduced in  Qt 5.6.</p>
<!-- @@@qHash -->
<!-- $$$operator*$$$operator*constQPoint&constQMatrix& -->
<h3 class="fn" id="operator-2a-1"><a name="operator-2a-1"></a><span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> <span class="name">operator*</span>(const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>point</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is the same as <i>matrix</i>.map(<i>point</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQPointF&constQMatrix& -->
<h3 class="fn" id="operator-2a-2"><a name="operator-2a-2"></a><span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> <span class="name">operator*</span>(const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;<i>point</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>Same as <i>matrix</i>.map(<i>point</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQLineF&constQMatrix& -->
<h3 class="fn" id="operator-2a-3"><a name="operator-2a-3"></a><span class="type"><a href="../qtcore/qlinef.html">QLineF</a></span> <span class="name">operator*</span>(const <span class="type"><a href="../qtcore/qlinef.html">QLineF</a></span> &amp;<i>line</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is the same as <i>matrix</i>.map(<i>line</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQLine&constQMatrix& -->
<h3 class="fn" id="operator-2a-4"><a name="operator-2a-4"></a><span class="type"><a href="../qtcore/qline.html">QLine</a></span> <span class="name">operator*</span>(const <span class="type"><a href="../qtcore/qline.html">QLine</a></span> &amp;<i>line</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is the same as <i>matrix</i>.map(<i>line</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQPolygonF&constQMatrix& -->
<h3 class="fn" id="operator-2a-5"><a name="operator-2a-5"></a><span class="type"><a href="qpolygonf.html">QPolygonF</a></span> <span class="name">operator*</span>(const <span class="type"><a href="qpolygonf.html">QPolygonF</a></span> &amp;<i>polygon</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is the same as <i>matrix</i>.map(<i>polygon</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQPolygon&constQMatrix& -->
<h3 class="fn" id="operator-2a-6"><a name="operator-2a-6"></a><span class="type"><a href="qpolygon.html">QPolygon</a></span> <span class="name">operator*</span>(const <span class="type"><a href="qpolygon.html">QPolygon</a></span> &amp;<i>polygon</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is the same as <i>matrix</i>.map(<i>polygon</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQRegion&constQMatrix& -->
<h3 class="fn" id="operator-2a-7"><a name="operator-2a-7"></a><span class="type"><a href="qregion.html">QRegion</a></span> <span class="name">operator*</span>(const <span class="type"><a href="qregion.html">QRegion</a></span> &amp;<i>region</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is the same as <i>matrix</i>.map(<i>region</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator*$$$operator*constQPainterPath&constQMatrix& -->
<h3 class="fn" id="operator-2a-8"><a name="operator-2a-8"></a><span class="type"><a href="qpainterpath.html">QPainterPath</a></span> <span class="name">operator*</span>(const <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> &amp;<i>path</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>This is the same as <i>matrix</i>.map(<i>path</i>).</p>
<p><b>See also </b><a href="qmatrix.html#map">QMatrix::map</a>().</p>
<!-- @@@operator* -->
<!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQMatrix& -->
<h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, const <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>Writes the given <i>matrix</i> to the given <i>stream</i> and returns a reference to the stream.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QMatrix& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="../qtcore/qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, <span class="type"><a href="qmatrix.html#QMatrix">QMatrix</a></span> &amp;<i>matrix</i>)</h3>
<p>Reads the given <i>matrix</i> from the given <i>stream</i> and returns a reference to the stream.</p>
<p><b>See also </b><a href="../qtcore/datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 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>