[Interest] QPixmap and threads

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Fri May 5 10:25:45 CEST 2017


Il 05/05/2017 09:05, maitai ha scritto:
> But still, I have hundreds of other QPixmaps used in threads, with no
> problem at all (creating, painting, etc). All is working fine for years,
> without any warning or so from Qt.

Well, not having problems doesn't imply that what you were doing was 
correct...

> Should I change also all these
> QPixmaps to QImages (with a conversion cost at the end of the threads)?

Yes. Note that the conversion cost may be extremely small: QPixmap these 
days is simply holding a QImage in the "right format" for display. If 
your QImage is already in that format, only a cheap refcount increase is 
needed, not a full format conversion.

>
> If QPixmaps are forbidden outside the main GUI thread, why is it not
> written in the documentation?

It is implied by the lack of "This class is reentrant" note in QPixmap 
documentation. It's also documented that way in other places, like

http://doc.qt.io/qt-5/thread-basics.html

See also slides 27+

> https://conf.qtcon.org/system/attachments/104/original/multithreading-with-qt.pdf?1473018682

Cheers,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170505/ced6a1ee/attachment.bin>


More information about the Interest mailing list