[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] qRgb and distribution
From:       Phil Thompson <phil () river-bank ! demon ! co ! uk>
Date:       2000-11-22 11:01:05
[Download RAW message or body]

Philippe Fremy wrote:
> 
>         Hi,
> 
> I don't know if this is fixed in PyQt 2.2, but in PyQt 2.1, the qRgb() function
> and the QColor::rgb() function which are both supposed to return a QRgb value
> are not consistent:
> 
> >>> qRgb(0,0,0)
> -16777216
> >>> col = QColor(0,0,0)
> >>> col
> <qt.QColor instance at 8111dc0>
> >>> col.rgb()
> (0, 0, 0)
> 
> The enum is a good idea but I still prefer the int value.  And since QRgb is a
> typedef int, I would have expected its value to be 0 for (0,0,0).

It's a little bit more complicated. In Qt there is "void QColor::rgb(int
*,int *,int *)" and "QRgb QColor::rgb()". Python doesn't have pointers
to the first method is implemented to return the 3 int values as a
tuple. Unfortunately this means that the two methods now have identical
argument signatures (they both take no arguments) and means that the
second method (the one you want to use) can never be called.

The solution is to give one of the methods a different name in PyQt (eg.
call the first one rgb_tuple()), but this will potentially break
existing scripts.

> Last thought: Is there a PyQt program repository ? That would help in code
> sharing and advertising. The PyQt homepage looks like a good place for this,
> no ?

I'm happy to have the information included on the homepage if somebody
wants to collect it.

Phil


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic