[PyQt] How to use a pixmap in a thread ?

Andreas Pakulat apaku at gmx.de
Sat Mar 6 09:02:59 GMT 2010


On 06.03.10 09:04:57, Vincent Vande Vyvre wrote:
> Hi,
> 
> In a image viewer I need to show a list of pictures into a trailer.
> 
> Since the source folder contain a large amount of pictures, I want to
> create they thumbnails
> in a thread, but PyQt return an error.
> 
>     QPixmap::scaled: Pixmap is a null pixmap
>     QPixmap: It is not safe to use pixmaps outside the GUI thread

You can't use QPixmap outside of the GUI thread, there's no way to do so
as they're often tied to resources of the underlying windowing system
(like XPixmap on X11). 

You can however use QImage in a separate thread and then later on
convert it to QPixmap or paint it directly.

Andreas

-- 
Your heart is pure, and your mind clear, and your soul devout.


More information about the PyQt mailing list