tools/qsize.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qsize.h" -
43#include "qdatastream.h" -
44#include "qdebug.h" -
45 -
46QT_BEGIN_NAMESPACE -
47 -
48/*! -
49 \class QSize -
50 \inmodule QtCore -
51 \ingroup painting -
52 -
53 \brief The QSize class defines the size of a two-dimensional -
54 object using integer point precision. -
55 -
56 A size is specified by a width() and a height(). It can be set in -
57 the constructor and changed using the setWidth(), setHeight(), or -
58 scale() functions, or using arithmetic operators. A size can also -
59 be manipulated directly by retrieving references to the width and -
60 height using the rwidth() and rheight() functions. Finally, the -
61 width and height can be swapped using the transpose() function. -
62 -
63 The isValid() function determines if a size is valid (a valid size -
64 has both width and height greater than zero). The isEmpty() -
65 function returns true if either of the width and height is less -
66 than, or equal to, zero, while the isNull() function returns true -
67 only if both the width and the height is zero. -
68 -
69 Use the expandedTo() function to retrieve a size which holds the -
70 maximum height and width of \e this size and a given -
71 size. Similarly, the boundedTo() function returns a size which -
72 holds the minimum height and width of \e this size and a given -
73 size. -
74 -
75 QSize objects can be streamed as well as compared. -
76 -
77 \sa QSizeF, QPoint, QRect -
78*/ -
79 -
80 -
81/***************************************************************************** -
82 QSize member functions -
83 *****************************************************************************/ -
84 -
85/*! -
86 \fn QSize::QSize() -
87 -
88 Constructs a size with an invalid width and height (i.e., isValid() -
89 returns false). -
90 -
91 \sa isValid() -
92*/ -
93 -
94/*! -
95 \fn QSize::QSize(int width, int height) -
96 -
97 Constructs a size with the given \a width and \a height. -
98 -
99 \sa setWidth(), setHeight() -
100*/ -
101 -
102/*! -
103 \fn bool QSize::isNull() const -
104 -
105 Returns true if both the width and height is 0; otherwise returns -
106 false. -
107 -
108 \sa isValid(), isEmpty() -
109*/ -
110 -
111/*! -
112 \fn bool QSize::isEmpty() const -
113 -
114 Returns true if either of the width and height is less than or -
115 equal to 0; otherwise returns false. -
116 -
117 \sa isNull(), isValid() -
118*/ -
119 -
120/*! -
121 \fn bool QSize::isValid() const -
122 -
123 Returns true if both the width and height is equal to or greater -
124 than 0; otherwise returns false. -
125 -
126 \sa isNull(), isEmpty() -
127*/ -
128 -
129/*! -
130 \fn int QSize::width() const -
131 -
132 Returns the width. -
133 -
134 \sa height(), setWidth() -
135*/ -
136 -
137/*! -
138 \fn int QSize::height() const -
139 -
140 Returns the height. -
141 -
142 \sa width(), setHeight() -
143*/ -
144 -
145/*! -
146 \fn void QSize::setWidth(int width) -
147 -
148 Sets the width to the given \a width. -
149 -
150 \sa rwidth(), width(), setHeight() -
151*/ -
152 -
153/*! -
154 \fn void QSize::setHeight(int height) -
155 -
156 Sets the height to the given \a height. -
157 -
158 \sa rheight(), height(), setWidth() -
159*/ -
160 -
161/*! -
162 Swaps the width and height values. -
163 -
164 \sa setWidth(), setHeight(), transposed() -
165*/ -
166 -
167void QSize::transpose() -
168{ -
169 int tmp = wd;
executed (the execution status of this line is deduced): int tmp = wd;
-
170 wd = ht;
executed (the execution status of this line is deduced): wd = ht;
-
171 ht = tmp;
executed (the execution status of this line is deduced): ht = tmp;
-
172}
executed: }
Execution Count:3
3
173 -
174/*! -
175 \fn QSize QSize::transposed() const -
176 \since 5.0 -
177 -
178 Returns a QSize with width and height swapped. -
179 -
180 \sa transpose() -
181*/ -
182 -
183/*! -
184 \fn void QSize::scale(int width, int height, Qt::AspectRatioMode mode) -
185 -
186 Scales the size to a rectangle with the given \a width and \a -
187 height, according to the specified \a mode: -
188 -
189 \list -
190 \li If \a mode is Qt::IgnoreAspectRatio, the size is set to (\a width, \a height). -
191 \li If \a mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle -
192 as large as possible inside (\a width, \a height), preserving the aspect ratio. -
193 \li If \a mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle -
194 as small as possible outside (\a width, \a height), preserving the aspect ratio. -
195 \endlist -
196 -
197 Example: -
198 \snippet code/src_corelib_tools_qsize.cpp 0 -
199 -
200 \sa setWidth(), setHeight(), scaled() -
201*/ -
202 -
203/*! -
204 \fn void QSize::scale(const QSize &size, Qt::AspectRatioMode mode) -
205 \overload -
206 -
207 Scales the size to a rectangle with the given \a size, according to -
208 the specified \a mode. -
209*/ -
210 -
211/*! -
212 \fn QSize QSize::scaled(int width, int height, Qt::AspectRatioMode mode) const -
213 \since 5.0 -
214 -
215 Return a size scaled to a rectangle with the given \a width and \a -
216 height, according to the specified \a mode. -
217 -
218 \sa scale() -
219*/ -
220 -
221/*! -
222 \overload -
223 \since 5.0 -
224 -
225 Return a size scaled to a rectangle with the given size \a s, -
226 according to the specified \a mode. -
227*/ -
228QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const -
229{ -
230 if (mode == Qt::IgnoreAspectRatio || wd == 0 || ht == 0) {
evaluated: mode == Qt::IgnoreAspectRatio
TRUEFALSE
yes
Evaluation Count:412
yes
Evaluation Count:2892
evaluated: wd == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2890
partially evaluated: ht == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2890
0-2892
231 return s;
executed: return s;
Execution Count:414
414
232 } else { -
233 bool useHeight;
executed (the execution status of this line is deduced): bool useHeight;
-
234 qint64 rw = qint64(s.ht) * qint64(wd) / qint64(ht);
executed (the execution status of this line is deduced): qint64 rw = qint64(s.ht) * qint64(wd) / qint64(ht);
-
235 -
236 if (mode == Qt::KeepAspectRatio) {
evaluated: mode == Qt::KeepAspectRatio
TRUEFALSE
yes
Evaluation Count:2888
yes
Evaluation Count:2
2-2888
237 useHeight = (rw <= s.wd);
executed (the execution status of this line is deduced): useHeight = (rw <= s.wd);
-
238 } else { // mode == Qt::KeepAspectRatioByExpanding
executed: }
Execution Count:2888
2888
239 useHeight = (rw >= s.wd);
executed (the execution status of this line is deduced): useHeight = (rw >= s.wd);
-
240 }
executed: }
Execution Count:2
2
241 -
242 if (useHeight) {
evaluated: useHeight
TRUEFALSE
yes
Evaluation Count:2852
yes
Evaluation Count:38
38-2852
243 return QSize(rw, s.ht);
executed: return QSize(rw, s.ht);
Execution Count:2852
2852
244 } else { -
245 return QSize(s.wd,
executed: return QSize(s.wd, qint32(qint64(s.wd) * qint64(ht) / qint64(wd)));
Execution Count:38
38
246 qint32(qint64(s.wd) * qint64(ht) / qint64(wd)));
executed: return QSize(s.wd, qint32(qint64(s.wd) * qint64(ht) / qint64(wd)));
Execution Count:38
38
247 } -
248 } -
249} -
250 -
251/*! -
252 \fn int &QSize::rwidth() -
253 -
254 Returns a reference to the width. -
255 -
256 Using a reference makes it possible to manipulate the width -
257 directly. For example: -
258 -
259 \snippet code/src_corelib_tools_qsize.cpp 1 -
260 -
261 \sa rheight(), setWidth() -
262*/ -
263 -
264/*! -
265 \fn int &QSize::rheight() -
266 -
267 Returns a reference to the height. -
268 -
269 Using a reference makes it possible to manipulate the height -
270 directly. For example: -
271 -
272 \snippet code/src_corelib_tools_qsize.cpp 2 -
273 -
274 \sa rwidth(), setHeight() -
275*/ -
276 -
277/*! -
278 \fn QSize &QSize::operator+=(const QSize &size) -
279 -
280 Adds the given \a size to \e this size, and returns a reference to -
281 this size. For example: -
282 -
283 \snippet code/src_corelib_tools_qsize.cpp 3 -
284*/ -
285 -
286/*! -
287 \fn QSize &QSize::operator-=(const QSize &size) -
288 -
289 Subtracts the given \a size from \e this size, and returns a -
290 reference to this size. For example: -
291 -
292 \snippet code/src_corelib_tools_qsize.cpp 4 -
293*/ -
294 -
295/*! -
296 \fn QSize &QSize::operator*=(qreal factor) -
297 \overload -
298 -
299 Multiplies both the width and height by the given \a factor, and -
300 returns a reference to the size. -
301 -
302 Note that the result is rounded to the nearest integer. -
303 -
304 \sa scale() -
305*/ -
306 -
307/*! -
308 \fn bool operator==(const QSize &s1, const QSize &s2) -
309 \relates QSize -
310 -
311 Returns true if \a s1 and \a s2 are equal; otherwise returns false. -
312*/ -
313 -
314/*! -
315 \fn bool operator!=(const QSize &s1, const QSize &s2) -
316 \relates QSize -
317 -
318 Returns true if \a s1 and \a s2 are different; otherwise returns false. -
319*/ -
320 -
321/*! -
322 \fn const QSize operator+(const QSize &s1, const QSize &s2) -
323 \relates QSize -
324 -
325 Returns the sum of \a s1 and \a s2; each component is added separately. -
326*/ -
327 -
328/*! -
329 \fn const QSize operator-(const QSize &s1, const QSize &s2) -
330 \relates QSize -
331 -
332 Returns \a s2 subtracted from \a s1; each component is subtracted -
333 separately. -
334*/ -
335 -
336/*! -
337 \fn const QSize operator*(const QSize &size, qreal factor) -
338 \relates QSize -
339 -
340 Multiplies the given \a size by the given \a factor, and returns -
341 the result rounded to the nearest integer. -
342 -
343 \sa QSize::scale() -
344*/ -
345 -
346/*! -
347 \fn const QSize operator*(qreal factor, const QSize &size) -
348 \overload -
349 \relates QSize -
350 -
351 Multiplies the given \a size by the given \a factor, and returns -
352 the result rounded to the nearest integer. -
353*/ -
354 -
355/*! -
356 \fn QSize &QSize::operator/=(qreal divisor) -
357 \overload -
358 -
359 Divides both the width and height by the given \a divisor, and -
360 returns a reference to the size. -
361 -
362 Note that the result is rounded to the nearest integer. -
363 -
364 \sa QSize::scale() -
365*/ -
366 -
367/*! -
368 \fn const QSize operator/(const QSize &size, qreal divisor) -
369 \relates QSize -
370 \overload -
371 -
372 Divides the given \a size by the given \a divisor, and returns the -
373 result rounded to the nearest integer. -
374 -
375 \sa QSize::scale() -
376*/ -
377 -
378/*! -
379 \fn QSize QSize::expandedTo(const QSize & otherSize) const -
380 -
381 Returns a size holding the maximum width and height of this size -
382 and the given \a otherSize. -
383 -
384 \sa boundedTo(), scale() -
385*/ -
386 -
387/*! -
388 \fn QSize QSize::boundedTo(const QSize & otherSize) const -
389 -
390 Returns a size holding the minimum width and height of this size -
391 and the given \a otherSize. -
392 -
393 \sa expandedTo(), scale() -
394*/ -
395 -
396 -
397 -
398/***************************************************************************** -
399 QSize stream functions -
400 *****************************************************************************/ -
401#ifndef QT_NO_DATASTREAM -
402/*! -
403 \fn QDataStream &operator<<(QDataStream &stream, const QSize &size) -
404 \relates QSize -
405 -
406 Writes the given \a size to the given \a stream, and returns a -
407 reference to the stream. -
408 -
409 \sa {Serializing Qt Data Types} -
410*/ -
411 -
412QDataStream &operator<<(QDataStream &s, const QSize &sz) -
413{ -
414 if (s.version() == 1)
partially evaluated: s.version() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:92
0-92
415 s << (qint16)sz.width() << (qint16)sz.height();
never executed: s << (qint16)sz.width() << (qint16)sz.height();
0
416 else -
417 s << (qint32)sz.width() << (qint32)sz.height();
executed: s << (qint32)sz.width() << (qint32)sz.height();
Execution Count:92
92
418 return s;
executed: return s;
Execution Count:92
92
419} -
420 -
421/*! -
422 \fn QDataStream &operator>>(QDataStream &stream, QSize &size) -
423 \relates QSize -
424 -
425 Reads a size from the given \a stream into the given \a size, and -
426 returns a reference to the stream. -
427 -
428 \sa {Serializing Qt Data Types} -
429*/ -
430 -
431QDataStream &operator>>(QDataStream &s, QSize &sz) -
432{ -
433 if (s.version() == 1) {
partially evaluated: s.version() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:100
0-100
434 qint16 w, h;
never executed (the execution status of this line is deduced): qint16 w, h;
-
435 s >> w; sz.rwidth() = w;
never executed (the execution status of this line is deduced): s >> w; sz.rwidth() = w;
-
436 s >> h; sz.rheight() = h;
never executed (the execution status of this line is deduced): s >> h; sz.rheight() = h;
-
437 }
never executed: }
0
438 else { -
439 qint32 w, h;
executed (the execution status of this line is deduced): qint32 w, h;
-
440 s >> w; sz.rwidth() = w;
executed (the execution status of this line is deduced): s >> w; sz.rwidth() = w;
-
441 s >> h; sz.rheight() = h;
executed (the execution status of this line is deduced): s >> h; sz.rheight() = h;
-
442 }
executed: }
Execution Count:100
100
443 return s;
executed: return s;
Execution Count:100
100
444} -
445#endif // QT_NO_DATASTREAM -
446 -
447#ifndef QT_NO_DEBUG_STREAM -
448QDebug operator<<(QDebug dbg, const QSize &s) { -
449 dbg.nospace() << "QSize(" << s.width() << ", " << s.height() << ')';
executed (the execution status of this line is deduced): dbg.nospace() << "QSize(" << s.width() << ", " << s.height() << ')';
-
450 return dbg.space();
executed: return dbg.space();
Execution Count:4
4
451} -
452#endif -
453 -
454 -
455 -
456/*! -
457 \class QSizeF -
458 \inmodule QtCore -
459 \brief The QSizeF class defines the size of a two-dimensional object -
460 using floating point precision. -
461 -
462 \ingroup painting -
463 -
464 A size is specified by a width() and a height(). It can be set in -
465 the constructor and changed using the setWidth(), setHeight(), or -
466 scale() functions, or using arithmetic operators. A size can also -
467 be manipulated directly by retrieving references to the width and -
468 height using the rwidth() and rheight() functions. Finally, the -
469 width and height can be swapped using the transpose() function. -
470 -
471 The isValid() function determines if a size is valid. A valid size -
472 has both width and height greater than or equal to zero. The -
473 isEmpty() function returns true if either of the width and height -
474 is \e less than (or equal to) zero, while the isNull() function -
475 returns true only if both the width and the height is zero. -
476 -
477 Use the expandedTo() function to retrieve a size which holds the -
478 maximum height and width of this size and a given -
479 size. Similarly, the boundedTo() function returns a size which -
480 holds the minimum height and width of this size and a given size. -
481 -
482 The QSizeF class also provides the toSize() function returning a -
483 QSize copy of this size, constructed by rounding the width and -
484 height to the nearest integers. -
485 -
486 QSizeF objects can be streamed as well as compared. -
487 -
488 \sa QSize, QPointF, QRectF -
489*/ -
490 -
491 -
492/***************************************************************************** -
493 QSizeF member functions -
494 *****************************************************************************/ -
495 -
496/*! -
497 \fn QSizeF::QSizeF() -
498 -
499 Constructs an invalid size. -
500 -
501 \sa isValid() -
502*/ -
503 -
504/*! -
505 \fn QSizeF::QSizeF(const QSize &size) -
506 -
507 Constructs a size with floating point accuracy from the given \a -
508 size. -
509 -
510 \sa toSize() -
511*/ -
512 -
513/*! -
514 \fn QSizeF::QSizeF(qreal width, qreal height) -
515 -
516 Constructs a size with the given \a width and \a height. -
517*/ -
518 -
519/*! -
520 \fn bool QSizeF::isNull() const -
521 -
522 Returns true if both the width and height are +0.0; otherwise returns -
523 false. -
524 -
525 \note Since this function treats +0.0 and -0.0 differently, sizes with -
526 zero width and height where either or both values have a negative -
527 sign are not defined to be null sizes. -
528 -
529 \sa isValid(), isEmpty() -
530*/ -
531 -
532/*! -
533 \fn bool QSizeF::isEmpty() const -
534 -
535 Returns true if either of the width and height is less than or -
536 equal to 0; otherwise returns false. -
537 -
538 \sa isNull(), isValid() -
539*/ -
540 -
541/*! -
542 \fn bool QSizeF::isValid() const -
543 -
544 Returns true if both the width and height is equal to or greater -
545 than 0; otherwise returns false. -
546 -
547 \sa isNull(), isEmpty() -
548*/ -
549 -
550/*! -
551 \fn int QSizeF::width() const -
552 -
553 Returns the width. -
554 -
555 \sa height(), setWidth() -
556*/ -
557 -
558/*! -
559 \fn int QSizeF::height() const -
560 -
561 Returns the height. -
562 -
563 \sa width(), setHeight() -
564*/ -
565 -
566/*! -
567 \fn void QSizeF::setWidth(qreal width) -
568 -
569 Sets the width to the given \a width. -
570 -
571 \sa width(), rwidth(), setHeight() -
572*/ -
573 -
574/*! -
575 \fn void QSizeF::setHeight(qreal height) -
576 -
577 Sets the height to the given \a height. -
578 -
579 \sa height(), rheight(), setWidth() -
580*/ -
581 -
582/*! -
583 \fn QSize QSizeF::toSize() const -
584 -
585 Returns an integer based copy of this size. -
586 -
587 Note that the coordinates in the returned size will be rounded to -
588 the nearest integer. -
589 -
590 \sa QSizeF() -
591*/ -
592 -
593/*! -
594 Swaps the width and height values. -
595 -
596 \sa setWidth(), setHeight(), transposed() -
597*/ -
598 -
599void QSizeF::transpose() -
600{ -
601 qreal tmp = wd;
executed (the execution status of this line is deduced): qreal tmp = wd;
-
602 wd = ht;
executed (the execution status of this line is deduced): wd = ht;
-
603 ht = tmp;
executed (the execution status of this line is deduced): ht = tmp;
-
604}
executed: }
Execution Count:6
6
605 -
606/*! -
607 \fn QSizeF QSizeF::transposed() const -
608 \since 5.0 -
609 -
610 Returns the size with width and height values swapped. -
611 -
612 \sa transpose() -
613*/ -
614 -
615/*! -
616 \fn void QSizeF::scale(qreal width, qreal height, Qt::AspectRatioMode mode) -
617 -
618 Scales the size to a rectangle with the given \a width and \a -
619 height, according to the specified \a mode. -
620 -
621 \list -
622 \li If \a mode is Qt::IgnoreAspectRatio, the size is set to (\a width, \a height). -
623 \li If \a mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle -
624 as large as possible inside (\a width, \a height), preserving the aspect ratio. -
625 \li If \a mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle -
626 as small as possible outside (\a width, \a height), preserving the aspect ratio. -
627 \endlist -
628 -
629 Example: -
630 \snippet code/src_corelib_tools_qsize.cpp 5 -
631 -
632 \sa setWidth(), setHeight(), scaled() -
633*/ -
634 -
635/*! -
636 \fn void QSizeF::scale(const QSizeF &size, Qt::AspectRatioMode mode) -
637 \overload -
638 -
639 Scales the size to a rectangle with the given \a size, according to -
640 the specified \a mode. -
641*/ -
642 -
643/*! -
644 \fn QSizeF QSizeF::scaled(qreal width, qreal height, Qt::AspectRatioMode mode) const -
645 \since 5.0 -
646 -
647 Returns a size scaled to a rectangle with the given \a width and -
648 \a height, according to the specified \a mode. -
649 -
650 \sa scale() -
651*/ -
652 -
653/*! -
654 \overload -
655 \since 5.0 -
656 -
657 Returns a size scaled to a rectangle with the given size \a s, -
658 according to the specified \a mode. -
659*/ -
660QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const -
661{ -
662 if (mode == Qt::IgnoreAspectRatio || qIsNull(wd) || qIsNull(ht)) {
evaluated: mode == Qt::IgnoreAspectRatio
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
evaluated: qIsNull(wd)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
partially evaluated: qIsNull(ht)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-6
663 return s;
executed: return s;
Execution Count:4
4
664 } else { -
665 bool useHeight;
executed (the execution status of this line is deduced): bool useHeight;
-
666 qreal rw = s.ht * wd / ht;
executed (the execution status of this line is deduced): qreal rw = s.ht * wd / ht;
-
667 -
668 if (mode == Qt::KeepAspectRatio) {
evaluated: mode == Qt::KeepAspectRatio
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
669 useHeight = (rw <= s.wd);
executed (the execution status of this line is deduced): useHeight = (rw <= s.wd);
-
670 } else { // mode == Qt::KeepAspectRatioByExpanding
executed: }
Execution Count:2
2
671 useHeight = (rw >= s.wd);
executed (the execution status of this line is deduced): useHeight = (rw >= s.wd);
-
672 }
executed: }
Execution Count:2
2
673 -
674 if (useHeight) {
evaluated: useHeight
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
675 return QSizeF(rw, s.ht);
executed: return QSizeF(rw, s.ht);
Execution Count:2
2
676 } else { -
677 return QSizeF(s.wd, s.wd * ht / wd);
executed: return QSizeF(s.wd, s.wd * ht / wd);
Execution Count:2
2
678 } -
679 } -
680} -
681 -
682/*! -
683 \fn int &QSizeF::rwidth() -
684 -
685 Returns a reference to the width. -
686 -
687 Using a reference makes it possible to manipulate the width -
688 directly. For example: -
689 -
690 \snippet code/src_corelib_tools_qsize.cpp 6 -
691 -
692 \sa rheight(), setWidth() -
693*/ -
694 -
695/*! -
696 \fn int &QSizeF::rheight() -
697 -
698 Returns a reference to the height. -
699 -
700 Using a reference makes it possible to manipulate the height -
701 directly. For example: -
702 -
703 \snippet code/src_corelib_tools_qsize.cpp 7 -
704 -
705 \sa rwidth(), setHeight() -
706*/ -
707 -
708/*! -
709 \fn QSizeF &QSizeF::operator+=(const QSizeF &size) -
710 -
711 Adds the given \a size to this size and returns a reference to -
712 this size. For example: -
713 -
714 \snippet code/src_corelib_tools_qsize.cpp 8 -
715*/ -
716 -
717/*! -
718 \fn QSizeF &QSizeF::operator-=(const QSizeF &size) -
719 -
720 Subtracts the given \a size from this size and returns a reference -
721 to this size. For example: -
722 -
723 \snippet code/src_corelib_tools_qsize.cpp 9 -
724*/ -
725 -
726/*! -
727 \fn QSizeF &QSizeF::operator*=(qreal factor) -
728 \overload -
729 -
730 Multiplies both the width and height by the given \a factor and -
731 returns a reference to the size. -
732 -
733 \sa scale() -
734*/ -
735 -
736/*! -
737 \fn bool operator==(const QSizeF &s1, const QSizeF &s2) -
738 \relates QSizeF -
739 -
740 Returns true if \a s1 and \a s2 are equal; otherwise returns -
741 false. -
742*/ -
743 -
744/*! -
745 \fn bool operator!=(const QSizeF &s1, const QSizeF &s2) -
746 \relates QSizeF -
747 -
748 Returns true if \a s1 and \a s2 are different; otherwise returns false. -
749*/ -
750 -
751/*! -
752 \fn const QSizeF operator+(const QSizeF &s1, const QSizeF &s2) -
753 \relates QSizeF -
754 -
755 Returns the sum of \a s1 and \a s2; each component is added separately. -
756*/ -
757 -
758/*! -
759 \fn const QSizeF operator-(const QSizeF &s1, const QSizeF &s2) -
760 \relates QSizeF -
761 -
762 Returns \a s2 subtracted from \a s1; each component is subtracted -
763 separately. -
764*/ -
765 -
766/*! -
767 \fn const QSizeF operator*(const QSizeF &size, qreal factor) -
768 -
769 \overload -
770 \relates QSizeF -
771 -
772 Multiplies the given \a size by the given \a factor and returns -
773 the result. -
774 -
775 \sa QSizeF::scale() -
776*/ -
777 -
778/*! -
779 \fn const QSizeF operator*(qreal factor, const QSizeF &size) -
780 -
781 \overload -
782 \relates QSizeF -
783 -
784 Multiplies the given \a size by the given \a factor and returns -
785 the result. -
786*/ -
787 -
788/*! -
789 \fn QSizeF &QSizeF::operator/=(qreal divisor) -
790 -
791 \overload -
792 -
793 Divides both the width and height by the given \a divisor and -
794 returns a reference to the size. -
795 -
796 \sa scale() -
797*/ -
798 -
799/*! -
800 \fn const QSizeF operator/(const QSizeF &size, qreal divisor) -
801 -
802 \relates QSizeF -
803 \overload -
804 -
805 Divides the given \a size by the given \a divisor and returns the -
806 result. -
807 -
808 \sa QSizeF::scale() -
809*/ -
810 -
811/*! -
812 \fn QSizeF QSizeF::expandedTo(const QSizeF & otherSize) const -
813 -
814 Returns a size holding the maximum width and height of this size -
815 and the given \a otherSize. -
816 -
817 \sa boundedTo(), scale() -
818*/ -
819 -
820/*! -
821 \fn QSizeF QSizeF::boundedTo(const QSizeF & otherSize) const -
822 -
823 Returns a size holding the minimum width and height of this size -
824 and the given \a otherSize. -
825 -
826 \sa expandedTo(), scale() -
827*/ -
828 -
829 -
830 -
831/***************************************************************************** -
832 QSizeF stream functions -
833 *****************************************************************************/ -
834#ifndef QT_NO_DATASTREAM -
835/*! -
836 \fn QDataStream &operator<<(QDataStream &stream, const QSizeF &size) -
837 \relates QSizeF -
838 -
839 Writes the given \a size to the given \a stream and returns a -
840 reference to the stream. -
841 -
842 \sa {Serializing Qt Data Types} -
843*/ -
844 -
845QDataStream &operator<<(QDataStream &s, const QSizeF &sz) -
846{ -
847 s << double(sz.width()) << double(sz.height());
executed (the execution status of this line is deduced): s << double(sz.width()) << double(sz.height());
-
848 return s;
executed: return s;
Execution Count:69
69
849} -
850 -
851/*! -
852 \fn QDataStream &operator>>(QDataStream &stream, QSizeF &size) -
853 \relates QSizeF -
854 -
855 Reads a size from the given \a stream into the given \a size and -
856 returns a reference to the stream. -
857 -
858 \sa {Serializing Qt Data Types} -
859*/ -
860 -
861QDataStream &operator>>(QDataStream &s, QSizeF &sz) -
862{ -
863 double w, h;
executed (the execution status of this line is deduced): double w, h;
-
864 s >> w;
executed (the execution status of this line is deduced): s >> w;
-
865 s >> h;
executed (the execution status of this line is deduced): s >> h;
-
866 sz.setWidth(qreal(w));
executed (the execution status of this line is deduced): sz.setWidth(qreal(w));
-
867 sz.setHeight(qreal(h));
executed (the execution status of this line is deduced): sz.setHeight(qreal(h));
-
868 return s;
executed: return s;
Execution Count:73
73
869} -
870#endif // QT_NO_DATASTREAM -
871 -
872#ifndef QT_NO_DEBUG_STREAM -
873QDebug operator<<(QDebug dbg, const QSizeF &s) { -
874 dbg.nospace() << "QSizeF(" << s.width() << ", " << s.height() << ')';
executed (the execution status of this line is deduced): dbg.nospace() << "QSizeF(" << s.width() << ", " << s.height() << ')';
-
875 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
876} -
877#endif -
878 -
879QT_END_NAMESPACE -
880 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial