Hi,
thx you both - I'll add a custom function in the win11 plugin.
From the responses I think it's worth thinking about a new function for
QColor... :)
Christian
Am 23.11.2025 um 20:26 schrieb Kai Uwe Broulik:
Hi,
Qt Quick has Qt.tint but I don’t see an equivalent in QColor. Perhaps
a C++ API should be added. In any case, it’s trivial, just doing alpha
blending:
QColor QQuickColorValueType::tint(const QColor &tintColor) const
{
int tintAlpha = tintColor.alpha();
if (tintAlpha == 0xFF)
return tintColor;
else if (tintAlpha == 0x00)
return *this;
// tint the base color and return the final color
const QColor baseColor = QColor::toRgb();
const qreal a = tintColor.alphaF();
const qreal inv_a = 1.0 - a;
const qreal r = tintColor.redF() * a + baseColor.redF() * inv_a;
const qreal g = tintColor.greenF() * a + baseColor.greenF() * inv_a;
const qreal b = tintColor.blueF() * a + baseColor.blueF() * inv_a;
return QColor::fromRgbF(r, g, b, a + inv_a * baseColor.alphaF());
}
Cheers
Kai Uwe
Am 23.11.25 um 20:17 schrieb Christian Ehrlicher via Development:
Hi,
for the window11 style plugin I like to merge two QColors to avoid a
double painting. The first color has no alpha but the second. Is
there anything ready to use in Qt (internals) or do I have to write
something by my own?
Thx,
Christian
--
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development