[PyKDE] question re python interface to QPixmapCache

Phil Thompson phil at riverbankcomputing.co.uk
Thu Mar 10 18:22:39 GMT 2005


On Wednesday 09 March 2005 7:15 pm, Tony Willis wrote:
> Hi
>
> I am trying to translate the 'traffic lights' example of the
> use of QPixmaps and QPixmapCache in Mark Summerfield's
> article in Qt Quarterly
> (http://doc.trolltech.com/qq/qq12-qpixmapcache.html)
> to python. My version is given at the end of this message.
>
> The appended code almost works, but the call to
> QPixmapCache in line 64 of the code croaks
> when a pixmap and its corresponding key have
> previously been inserted into the QPixmapCache. Am I doing
> something incredibly silly, or is there an
> actual problem with the python interface to QPixmapCache?
>
> Note: the esssentially equivalent code (commented out)
> that uses a standard python dict to store the pixmaps
> works fine.
>
> System: RH9 linux
>         python 2.3.4
>         PyQt-x11-gpl-3.12
>         sip 4.0.1
>
> Thanks for any advice. Could you please copy me by e-mail
> directly, as I am not a susbscriber to the PyKde interest
> group.

There are two C++ variants of QPixmapCache::insert() and I've wrongly wrapped 
the obsolete one that means you have to mess with object ownership depending 
on the result. Something like...

    if QPixmapCache.insert(key, pixmap1):
        sip.transfer(pixmap1, True)

I will wrap the correct variant in the next snapshot.

Phil




More information about the PyQt mailing list