[PyKDE] Strange QColor behavior when passing rgb in constructor.
phil at riverbankcomputing.co.uk
Thu Mar 10 17:57:30 GMT 2005
On Wednesday 09 March 2005 12:16 pm, Truls A. Tangstad wrote:
> I've been testing and debugging to find a problem in our code where
> plots just weren't drawn (or rather drawn in white on white
> background), which I finally tracked down to be the way I used QColor.
> I assumed that passing a combined rgb-value as an int to QColor()
> would create the right color according to , but I kept getting
> white, no matter what rgb value I set. What was even stranger was that
> the QColor-methods red(), green() and blue() returned the correct
> value for the created QColor-instance.
> I found that the problem was the default value for the pixel-parameter
> (documented in  to be pixel=0xffffffff). When setting the value to
> -1 or 0xffffffff explicitly, everything worked fine. When omitting it,
> the color displayed as white (might be specific to my system).
> Also, creating an empty QColor, then setting rgb with setRgb() works
> I created a small example (attached) showing the problem, creating two
> QMainWindows that should be painted red, but for me displays as one
> white and one red. A C++ port of the code did not have the bug.
> My software versions are as follows (running debian unstable):
> python2.3-qt3 3.13-4
> libqt3c102-mt 3.3.3-8
> libqt3c102 3.3.3-8
> And yes.. I know this is really a minor issue, as I can easily work
> around it, but I hope that fixing the problem will keep others from
> spending as much time as I did to try to figure out why their code
>  - http://doc.trolltech.com/3.3/qcolor.html#QColor-4
They are both red for me.
More information about the PyQt