QtBase  v6.3.1
src_corelib_tools_qsize.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the documentation of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
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 The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** BSD License Usage
18 ** Alternatively, you may use this file under the terms of the BSD license
19 ** as follows:
20 **
21 ** "Redistribution and use in source and binary forms, with or without
22 ** modification, are permitted provided that the following conditions are
23 ** met:
24 ** * Redistributions of source code must retain the above copyright
25 ** notice, this list of conditions and the following disclaimer.
26 ** * Redistributions in binary form must reproduce the above copyright
27 ** notice, this list of conditions and the following disclaimer in
28 ** the documentation and/or other materials provided with the
29 ** distribution.
30 ** * Neither the name of The Qt Company Ltd nor the names of its
31 ** contributors may be used to endorse or promote products derived
32 ** from this software without specific prior written permission.
33 **
34 **
35 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 **
47 ** $QT_END_LICENSE$
48 **
49 ****************************************************************************/
50 
52 QSize t1(10, 12);
53 t1.scale(60, 60, Qt::IgnoreAspectRatio);
54 // t1 is (60, 60)
55 
56 QSize t2(10, 12);
58 // t2 is (50, 60)
59 
60 QSize t3(10, 12);
62 // t3 is (60, 72)
64 
65 
67 QSize size(100, 10);
68 size.rwidth() += 20;
69 
70 // size becomes (120,10)
72 
73 
75 QSize size(100, 10);
76 size.rheight() += 5;
77 
78 // size becomes (100,15)
80 
81 
83 QSize s( 3, 7);
84 QSize r(-1, 4);
85 s += r;
86 
87 // s becomes (2,11)
89 
90 
92 QSize s( 3, 7);
93 QSize r(-1, 4);
94 s -= r;
95 
96 // s becomes (4,3)
98 
99 
101 QSizeF t1(10, 12);
102 t1.scale(60, 60, Qt::IgnoreAspectRatio);
103 // t1 is (60, 60)
104 
105 QSizeF t2(10, 12);
106 t2.scale(60, 60, Qt::KeepAspectRatio);
107 // t2 is (50, 60)
108 
109 QSizeF t3(10, 12);
111 // t3 is (60, 72)
113 
114 
116 QSizeF size(100.3, 10);
117 size.rwidth() += 20.5;
118 
119  // size becomes (120.8,10)
121 
122 
124 QSizeF size(100, 10.2);
125 size.rheight() += 5.5;
126 
127 // size becomes (100,15.7)
129 
130 
132 QSizeF s( 3, 7);
133 QSizeF r(-1, 4);
134 s += r;
135 
136 // s becomes (2,11)
138 
139 
141 QSizeF s( 3, 7);
142 QSizeF r(-1, 4);
143 s -= r;
144 
145 // s becomes (4,3)
The QSizeF class defines the size of a two-dimensional object using floating point precision.
Definition: qsize.h:235
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
void scale(int w, int h, Qt::AspectRatioMode mode) noexcept
Definition: qsize.h:172
@ KeepAspectRatioByExpanding
Definition: qnamespace.h:1214
@ KeepAspectRatio
Definition: qnamespace.h:1213
@ IgnoreAspectRatio
Definition: qnamespace.h:1212
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLdouble s
[6]
Definition: qopenglext.h:235
QSize t3(10, 12)
QSize r(-1, 4)
QSize t1(10, 12)
[0]
QSize size(100, 10)
[0]
QSize t2(10, 12)
QSize s(3, 7)
[2]