Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_corelib_tools_qsize.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QSize>
5
6void examples()
7{
8 {
9 //! [0]
10 QSize t1(10, 12);
11 t1.scale(60, 60, Qt::IgnoreAspectRatio);
12 // t1 is (60, 60)
13
14 QSize t2(10, 12);
15 t2.scale(60, 60, Qt::KeepAspectRatio);
16 // t2 is (50, 60)
17
18 QSize t3(10, 12);
19 t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
20 // t3 is (60, 72)
21 //! [0]
22 }
23
24 {
25 //! [1]
26 QSize size(100, 10);
27 size.rwidth() += 20;
28
29 // size becomes (120,10)
30 //! [1]
31 }
32
33 {
34 //! [2]
35 QSize size(100, 10);
36 size.rheight() += 5;
37
38 // size becomes (100,15)
39 //! [2]
40 }
41
42 {
43 //! [3]
44 QSize s( 3, 7);
45 QSize r(-1, 4);
46 s += r;
47
48 // s becomes (2,11)
49 //! [3]
50 }
51
52 {
53 //! [4]
54 QSize s( 3, 7);
55 QSize r(-1, 4);
56 s -= r;
57
58 // s becomes (4,3)
59 //! [4]
60 }
61
62 {
63 //! [5]
64 QSizeF t1(10, 12);
65 t1.scale(60, 60, Qt::IgnoreAspectRatio);
66 // t1 is (60, 60)
67
68 QSizeF t2(10, 12);
69 t2.scale(60, 60, Qt::KeepAspectRatio);
70 // t2 is (50, 60)
71
72 QSizeF t3(10, 12);
73 t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
74 // t3 is (60, 72)
75 //! [5]
76 }
77
78 {
79 //! [6]
80 QSizeF size(100.3, 10);
81 size.rwidth() += 20.5;
82
83 // size becomes (120.8,10)
84 //! [6]
85 }
86
87 {
88 //! [7]
89 QSizeF size(100, 10.2);
90 size.rheight() += 5.5;
91
92 // size becomes (100,15.7)
93 //! [7]
94 }
95
96 {
97 //! [8]
98 QSizeF s( 3, 7);
99 QSizeF r(-1, 4);
100 s += r;
101
102 // s becomes (2,11)
103 //! [8]
104 }
105
106 {
107 //! [9]
108 QSizeF s( 3, 7);
109 QSizeF r(-1, 4);
110 s -= r;
111
112 // s becomes (4,3)
113 //! [9]
114 }
115}
bool examples()
[3]