What to do about KColor?

Andreas Pakulat apaku at gmx.de
Mon May 28 21:47:45 BST 2007

On 28.05.07 21:34:01, Thomas Zander wrote:
> On Monday 28 May 2007 20:40:58 Alex Merry wrote:
> > I agree with this - the function name is very confusing, because it
> > _doesn't_ blend two colours.  It overlays the second on the first.
> That entirely depends on your definition of what a color is.
> Beginning in Qt4, and in other toolkits quite a bit longer, the definition 
> of a color is *including* the alpha channel.  And with that in mind, the 
> blend method indeed does exactly what it says.

Hmm, but why is the alpha channel of the first color not taken into
account then? How does a user blend two colors that he gets from the
palette where he doesn't know wether they have an alpha value or not? Do
I have to check for that and then just do the blend and if the 2nd color
doesn't have an alpha value then I need to set one? Sorry but thats just
unintuitive API.

> As I (and Aaron) stated elsewhere;  lets see where actual apps end up 
> using this and avoid this 'design by committee' re-painting of the 
> bikeshed.

So you want some code? How's this:

            QColor background = QApplication::palette().window().color();
            QBrush foreground = ret->foreground();
            if( background.alphaF() > 0 )
                foreground.setColor(KGraphicsUtils::blendColor(QApplication::palette().highlight().color(), background));
                foreground.setColor(KGraphicsUtils::blendColor(QApplication::palette().highlight().color(), background));


Unfortunately there has been a bug introduced recently in the
makebuilder which leads to it not showing the highlighting. I didn't
have time to look into that yet.

Instead of the above I'd like to do just

QBrush b = ret->foreground();
b.setColor( KGraphicsUtil::blendColor(


A vivid and creative mind characterizes you.

More information about the kde-core-devel mailing list