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
colorpicker.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#
include
"colorpicker.h"
5
6
#
include
<
QtCore
/
qlogging
.
h
>
7
8
void
MyColorPicker
::
setEncodedColor
(
double
value)
9
{
10
if
(value < 0.0 || !(value < 1.0)) {
11
qWarning(
"Bad value, %f, cannot get color from it!"
, value);
12
return
;
13
}
14
m_encodedColor = value;
15
}
16
17
QBindable
<
double
>
MyColorPicker
::
bindableEncodedColor
()
18
{
19
return
QBindable<
double
>(&m_encodedColor);
20
}
21
22
QColor
MyColorPicker
::decodeColor()
23
{
24
const
double
encodedValue = m_encodedColor;
25
constexpr
int
rgbFirst = 0;
26
constexpr
int
rgbLast = 256 * 256 * 256;
27
const
QRgb rgb = rgbFirst + (rgbLast - rgbFirst) * encodedValue;
28
return
QColor(rgb);
29
}
MyColorPicker
Definition
colorpicker.h:10
MyColorPicker::bindableEncodedColor
QBindable< double > bindableEncodedColor()
Definition
colorpicker.cpp:17
MyColorPicker::setEncodedColor
void setEncodedColor(double value)
Definition
colorpicker.cpp:8
qtdeclarative
src
qml
doc
snippets
qmltc
colorpicker.cpp
Generated on
for Qt by
1.14.0