QDataStream
doesn't work because it's expecting a PNG image from the stream.
I wouldn't use the temp file approach either since it may still construct a QPixmap
under the hood. In fact, QIcon
is not guaranteed to be thread-safe and the use in non-GUI thread should be avoided.
I would just keep the byte array as is and pass it back to the GUI thread. Convert it into a QPixmap then a QIcon when you need to show it. It's not really so heavy a computation anyway.