File: qmatrix.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (484 lines) | stat: -rw-r--r-- 55,007 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qmatrix.cpp -->
  <title>Qt 4.8: QMatrix Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QMatrix</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<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>
<h1 class="title">QMatrix Class Reference</h1>
<!-- $$$QMatrix-brief -->
<p>The QMatrix class specifies 2D transformations of a coordinate system. <a href="#details">More...</a></p>
<!-- @@@QMatrix -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QMatrix&gt;</span></pre><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>
<li><a href="qmatrix-qt3.html">Qt 3 support members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<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-3">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-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> = 0 ) 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-3">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"> QPointF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-4">map</a></b> ( const QPointF &amp; <i>point</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-5">map</a></b> ( const QPoint &amp; <i>point</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLineF </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-6">map</a></b> ( const QLineF &amp; <i>line</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLine </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#map-7">map</a></b> ( const QLine &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-8">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-9">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-10">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-11">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-2">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> ( 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>
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#qFuzzyCompare-6">qFuzzyCompare</a></b> ( const QMatrix &amp; <i>m1</i>, const QMatrix &amp; <i>m2</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qmatrix.html#operator-2a-36">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-37">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-38">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-39">operator*</a></b> ( const QLine &amp; <i>line</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-40">operator*</a></b> ( const QPolygon &amp; <i>polygon</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-41">operator*</a></b> ( const QPolygonF &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-42">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-43">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-112">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-58">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>stream</i>, QMatrix &amp; <i>matrix</i> )</td></tr>
</table>
<a name="details"></a>
<!-- $$$QMatrix-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QMatrix 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. QMatrix, 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 QMatrix 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="#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 QMatrix 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>QMatrix provides the <a href="qmatrix.html#isIdentity">isIdentity</a>() function which returns true if the matrix is the identity matrix, and the <a href="qmatrix.html#isInvertible">isInvertible</a>() function which returns true 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, QMatrix provides the <a href="qmatrix.html#determinant">determinant</a>() function returning the matrix's determinant.</p>
<p>Finally, the QMatrix 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 QMatrix. For example:</p>
<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"><a href="qt.html">Qt</a></span><span class="operator">::</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></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"><a href="qt.html">Qt</a></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>
<p>Although these functions are very convenient, it can be more efficient to build a QMatrix 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>
<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"><a href="qt.html">Qt</a></span><span class="operator">::</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></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">QMatrix</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"><a href="qt.html">Qt</a></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>
<a name="basic-matrix-operations"></a>
<h3>Basic Matrix Operations</h3>
<p class="centerAlign"><img src="images/qmatrix-representation.png" alt="" /></p><p>A QMatrix object contains a 3 x 3 matrix. The <tt>dx</tt> and <tt>dy</tt> elements specify horizontal and vertical translation. The <tt>m11</tt> and <tt>m22</tt> elements specify horizontal and vertical scaling. And finally, the <tt>m21</tt> and <tt>m12</tt> elements specify horizontal and vertical <i>shearing</i>.</p>
<p>QMatrix 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 <tt>dx</tt> and <tt>dy</tt> will move the coordinate system <tt>dx</tt> units along the X axis and <tt>dy</tt> units along the Y axis. Scaling can be done by setting <tt>m11</tt> and <tt>m22</tt>. For example, setting <tt>m11</tt> to 2 and <tt>m22</tt> to 1.5 will double the height and increase the width by 50%. The identity matrix has <tt>m11</tt> and <tt>m22</tt> set to 1 (all others are set to 0) mapping a point to itself. Shearing is controlled by <tt>m12</tt> and <tt>m21</tt>. 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>
<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">QMatrix</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">QMatrix</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">QMatrix</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">QMatrix</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"><a href="qt.html">Qt</a></span><span class="operator">::</span>blue<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></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"><a href="qt.html">Qt</a></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><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="demos-affine.html">Affine Transformations Demo</a>, and <a href="painting-transformations.html">Transformations Example</a>.</p>
<!-- @@@QMatrix -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QMatrix[overload1]$$$QMatrix -->
<h3 class="fn"><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 <tt>m11</tt> and <tt>m22</tt> (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"><a name="QMatrix-3"></a>QMatrix::<span class="name">QMatrix</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m11</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m12</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m21</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m22</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>dx</i>, <span class="type"><a href="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$$$QMatrixconstQMatrix& -->
<h3 class="fn"><a name="QMatrix-4"></a>QMatrix::<span class="name">QMatrix</span> ( const <span class="type">QMatrix</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"><a name="m11"></a><span class="type"><a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@m11 -->
<!-- $$$m12[overload1]$$$m12 -->
<h3 class="fn"><a name="m12"></a><span class="type"><a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@m12 -->
<!-- $$$m21[overload1]$$$m21 -->
<h3 class="fn"><a name="m21"></a><span class="type"><a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@m21 -->
<!-- $$$m22[overload1]$$$m22 -->
<h3 class="fn"><a name="m22"></a><span class="type"><a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@m22 -->
<!-- $$$determinant[overload1]$$$determinant -->
<h3 class="fn"><a name="determinant"></a><span class="type"><a href="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"><a name="dx"></a><span class="type"><a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@dx -->
<!-- $$$dy[overload1]$$$dy -->
<h3 class="fn"><a name="dy"></a><span class="type"><a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@dy -->
<!-- $$$inverted[overload1]$$$invertedbool* -->
<h3 class="fn"><a name="inverted"></a><span class="type">QMatrix</span> QMatrix::<span class="name">inverted</span> ( <span class="type">bool</span> * <i>invertible</i> = 0 ) 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"><a name="isIdentity"></a><span class="type">bool</span> QMatrix::<span class="name">isIdentity</span> () const</h3>
<p>Returns true if the matrix is the identity matrix, otherwise returns false.</p>
<p><b>See also </b><a href="qmatrix.html#reset">reset</a>().</p>
<!-- @@@isIdentity -->
<!-- $$$isInvertible[overload1]$$$isInvertible -->
<h3 class="fn"><a name="isInvertible"></a><span class="type">bool</span> QMatrix::<span class="name">isInvertible</span> () const</h3>
<p>Returns true if the matrix is invertible, otherwise returns false.</p>
<p><b>See also </b><a href="qmatrix.html#inverted">inverted</a>().</p>
<!-- @@@isInvertible -->
<!-- $$$map[overload1]$$$mapqrealqrealqreal*qreal* -->
<h3 class="fn"><a name="map"></a><span class="type">void</span> QMatrix::<span class="name">map</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>x</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>y</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> * <i>tx</i>, <span class="type"><a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@map -->
<!-- $$$map$$$mapintintint*int* -->
<h3 class="fn"><a name="map-3"></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$$$mapconstQPointF& -->
<h3 class="fn"><a name="map-4"></a><span class="type"><a href="qpointf.html">QPointF</a></span> QMatrix::<span class="name">map</span> ( const <span class="type"><a href="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="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$$$mapconstQPoint& -->
<h3 class="fn"><a name="map-5"></a><span class="type"><a href="qpoint.html">QPoint</a></span> QMatrix::<span class="name">map</span> ( const <span class="type"><a href="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="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$$$mapconstQLineF& -->
<h3 class="fn"><a name="map-6"></a><span class="type"><a href="qlinef.html">QLineF</a></span> QMatrix::<span class="name">map</span> ( const <span class="type"><a href="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="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$$$mapconstQLine& -->
<h3 class="fn"><a name="map-7"></a><span class="type"><a href="qline.html">QLine</a></span> QMatrix::<span class="name">map</span> ( const <span class="type"><a href="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="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$$$mapconstQPolygonF& -->
<h3 class="fn"><a name="map-8"></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"><a name="map-9"></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"><a name="map-10"></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"><a name="map-11"></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"><a name="mapRect"></a><span class="type"><a href="qrectf.html">QRectF</a></span> QMatrix::<span class="name">mapRect</span> ( const <span class="type"><a href="qrectf.html">QRectF</a></span> &amp; <i>rectangle</i> ) const</h3>
<p>Creates and returns a <a href="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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@mapRect -->
<!-- $$$mapRect$$$mapRectconstQRect& -->
<h3 class="fn"><a name="mapRect-2"></a><span class="type"><a href="qrect.html">QRect</a></span> QMatrix::<span class="name">mapRect</span> ( const <span class="type"><a href="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="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"><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="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 <tt>matrix.map(QPolygon(rectangle))</tt> is not always the same as <tt>matrix.mapToPolygon(rectangle)</tt>.</p>
<p><b>See also </b><a href="qmatrix.html#mapRect">mapRect</a>() and <a href="qmatrix.html#basic-matrix-operations" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@mapToPolygon -->
<!-- $$$reset[overload1]$$$reset -->
<h3 class="fn"><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 <tt>m11</tt> and <tt>m22</tt> (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" class="obsolete">Basic Matrix Operations</a>.</p>
<!-- @@@reset -->
<!-- $$$rotate[overload1]$$$rotateqreal -->
<h3 class="fn"><a name="rotate"></a><span class="type">QMatrix</span> &amp; QMatrix::<span class="name">rotate</span> ( <span class="type"><a href="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"><a name="scale"></a><span class="type">QMatrix</span> &amp; QMatrix::<span class="name">scale</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>sx</i>, <span class="type"><a href="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"><a name="setMatrix"></a><span class="type">void</span> QMatrix::<span class="name">setMatrix</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m11</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m12</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m21</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>m22</i>, <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>dx</i>, <span class="type"><a href="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"><a name="shear"></a><span class="type">QMatrix</span> &amp; QMatrix::<span class="name">shear</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>sh</i>, <span class="type"><a href="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"><a name="translate"></a><span class="type">QMatrix</span> &amp; QMatrix::<span class="name">translate</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>dx</i>, <span class="type"><a href="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"><a name="operator-QVariant"></a>QMatrix::<span class="name">operator QVariant</span> () const</h3>
<p>Returns the matrix as a <a href="qvariant.html">QVariant</a>.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@operator QVariant -->
<!-- $$$operator!=[overload1]$$$operator!=constQMatrix& -->
<h3 class="fn"><a name="operator-not-eq"></a><span class="type">bool</span> QMatrix::<span class="name">operator!=</span> ( const <span class="type">QMatrix</span> &amp; <i>matrix</i> ) const</h3>
<p>Returns true if this matrix is not equal to the given <i>matrix</i>, otherwise returns false.</p>
<!-- @@@operator!= -->
<!-- $$$operator*[overload1]$$$operator*constQMatrix& -->
<h3 class="fn"><a name="operator-2a"></a><span class="type">QMatrix</span> QMatrix::<span class="name">operator*</span> ( const <span class="type">QMatrix</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"><a name="operator-2a-eq"></a><span class="type">QMatrix</span> &amp; QMatrix::<span class="name">operator*=</span> ( const <span class="type">QMatrix</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=constQMatrix& -->
<h3 class="fn"><a name="operator-eq"></a><span class="type">QMatrix</span> &amp; QMatrix::<span class="name">operator=</span> ( const <span class="type">QMatrix</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"><a name="operator-eq-eq"></a><span class="type">bool</span> QMatrix::<span class="name">operator==</span> ( const <span class="type">QMatrix</span> &amp; <i>matrix</i> ) const</h3>
<p>Returns true if this matrix is equal to the given <i>matrix</i>, otherwise returns false.</p>
<!-- @@@operator== -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qFuzzyCompare$$$qFuzzyCompareconstQMatrix&constQMatrix& -->
<h3 class="fn"><a name="qFuzzyCompare-6"></a><span class="type">bool</span> <span class="name">qFuzzyCompare</span> ( const <span class="type">QMatrix</span> &amp; <i>m1</i>, const <span class="type">QMatrix</span> &amp; <i>m2</i> )</h3>
<p>The qFuzzyCompare function is for comparing two matrices using a fuzziness factor.</p>
<p>Returns true 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 -->
<!-- $$$operator*$$$operator*constQPoint&constQMatrix& -->
<h3 class="fn"><a name="operator-2a-36"></a><span class="type"><a href="qpoint.html">QPoint</a></span> <span class="name">operator*</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp; <i>point</i>, const <span class="type">QMatrix</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"><a name="operator-2a-37"></a><span class="type"><a href="qpointf.html">QPointF</a></span> <span class="name">operator*</span> ( const <span class="type"><a href="qpointf.html">QPointF</a></span> &amp; <i>point</i>, const <span class="type">QMatrix</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"><a name="operator-2a-38"></a><span class="type"><a href="qlinef.html">QLineF</a></span> <span class="name">operator*</span> ( const <span class="type"><a href="qlinef.html">QLineF</a></span> &amp; <i>line</i>, const <span class="type">QMatrix</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"><a name="operator-2a-39"></a><span class="type"><a href="qline.html">QLine</a></span> <span class="name">operator*</span> ( const <span class="type"><a href="qline.html">QLine</a></span> &amp; <i>line</i>, const <span class="type">QMatrix</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*constQPolygon&constQMatrix& -->
<h3 class="fn"><a name="operator-2a-40"></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">QMatrix</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*constQPolygonF&constQMatrix& -->
<h3 class="fn"><a name="operator-2a-41"></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">QMatrix</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"><a name="operator-2a-42"></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">QMatrix</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"><a name="operator-2a-43"></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">QMatrix</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<<$$$operator<<QDataStream&constQMatrix& -->
<h3 class="fn"><a name="operator-lt-lt-112"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp; <span class="name">operator&lt;&lt;</span> ( <span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp; <i>stream</i>, const <span class="type">QMatrix</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="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>$$$operator>>QDataStream&QMatrix& -->
<h3 class="fn"><a name="operator-gt-gt-58"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp; <span class="name">operator&gt;&gt;</span> ( <span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp; <i>stream</i>, <span class="type">QMatrix</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="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2012 Nokia Corporation and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      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.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>