[Qt-interest] QtColor problem
benswerts at telenet.be
benswerts at telenet.be
Thu Jul 23 20:29:57 CEST 2009
I don't have the source available at the moment but AFAIK the color components are stored as unsigned short ints internally. So the red component is converted from 50 (out of 255) into 12850 (out of 65535). When you retrieve the color component with QColor::red(), it will be 50 again.
How are you visualizing the color? As you are using a very low alpha component, the color is almost completely transparent. Using this color for elements that don't support transparency might have the effect that the alpha component is multiplied in. This would change QColor(50, 10, 20, 1) into QColor(50/255, 10/255, 20/255). Back in 8 bit land this becomes pure black.
Hope it helps!
Greets,
Ben
>hi everybody!
>
>I'm trying to obtain variable QColor by initializing it manually in my
>code, but I only obtain black color.
>
>I executed with the QtCreator debugger and the problem it's so weird.
>
>For example:
>
>QColor c(50, 10, 20, 1)
>
>it enters to the constructor of QColor with the right values, and then goes
>to another function of QColor to initialize the values and always put this
>values: (12850, 2570, 51440, 257)
>
>So, this values are very different from (50, 10, 20, 1)
>
>I only include <QtGui/QColor> and I don't know if there somethins missing
>or my Qt version is old. The qt version I use is 4.5, it's not too old.
>
>Thanks!
>
More information about the Qt-interest-old
mailing list