Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qmultimediautils.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
7
9{
10 int integral = int(floor(value));
11 value -= qreal(integral);
12 if (value == 0.)
13 return {integral, 1};
14
15 const int dMax = 1000;
16 int n1 = 0, d1 = 1, n2 = 1, d2 = 1;
17 qreal mid = 0.;
18 while (d1 <= dMax && d2 <= dMax) {
19 mid = qreal(n1 + n2) / (d1 + d2);
20
21 if (qAbs(value - mid) < 0.000001) {
22 break;
23 } else if (value > mid) {
24 n1 = n1 + n2;
25 d1 = d1 + d2;
26 } else {
27 n2 = n1 + n2;
28 d2 = d1 + d2;
29 }
30 }
31
32 if (d1 + d2 <= dMax)
33 return {n1 + n2 + integral * (d1 + d2), d1 + d2};
34 else if (d2 < d1)
35 return { n2 + integral * d2, d2 };
36 else
37 return { n1 + integral * d1, d1 };
38}
39
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QT_BEGIN_NAMESPACE Fraction qRealToFraction(qreal value)
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
double qreal
Definition qtypes.h:92
QDate d1(1995, 5, 17)
[0]
QDate d2(1995, 5, 20)