[PyQt] QIODevice+QImageReader oddity ?

Attila Csipa pyqt at csipa.in.rs
Tue Apr 21 20:56:13 BST 2009

On Tuesday 21 April 2009 18:14:14 you wrote:
> Don't you need to open the device for reading before passing it to QImage ?
> For me, just adding:
> iop.open(QIODevice.ReadOnly)
> makes everything work fine.

Thanks, you're right, that did the trick. The source of my confusion was the 
following paragraph in the QImageReader docs:

If the device is not already open, QImageReader will attempt to open the 
device in QIODevice.ReadOnly mode by calling open(). Note that this does not 
work for certain devices, such as QProcess, QTcpSocket and QUdpSocket, where 
more logic is required to open the device.

So, this behaviour is not something to be relied on (not sure if this is a 
quiestion of Qt, PyQt or a documentation error).

More information about the PyQt mailing list