Don't you need to open the device for reading before passing it to QImage ?<br><br>For me, just adding:<br><br>iop.open(QIODevice.ReadOnly)<br><br><br>makes everything work fine.<br><br clear="all">-- <br>Barbier de Reuille Pierre<br>
<br><br><div class="gmail_quote">2009/4/21 Attila Csipa <span dir="ltr"><pyqt@csipa.in.rs></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello, I'm fairly new to PyQt (have been using Qt from good old C++<br>
previously) and have a strange issue I did not find a solution to in the<br>
docs or the archives. In the code snippet below, the image reader works<br>
if I specify the filename constructor, but not when I try to use it via<br>
an QIODevice (like QFile or QBuffer). I'm on Ubuntu 9.04, using PyQt<br>
4.4.4-2 with Qt 4.5.0-0 (these are the Ubuntu defaults). Am I missing<br>
something trivial or is this a known issue ? Thanks in advance.<br>
<br>
from PyQt4.QtGui import *<br>
from PyQt4.QtCore import *<br>
<br>
def chkerror(reader):<br>
if reader.error():<br>
print reader.errorString()<br>
<br>
iod = QFile("poster_100hours.jpg")<br>
print iod.size()<br>
<br>
#reader = QImageReader("poster_100hours.jpg")<br>
#reader = QImageReader()<br>
reader = QImageReader(iod)<br>
#reader.setDevice(iod)<br>
<br>
chkerror(reader)<br>
print reader.size()<br>
chkerror(reader)<br>
img = reader.read()<br>
chkerror(reader)<br>
print img.size()<br>
<br>
<br>
----<br>
with filename constructor:<br>
287998<br>
PyQt4.QtCore.QSize(1280, 1811)<br>
PyQt4.QtCore.QSize(1280, 1811)<br>
<br>
with QFile iodevice constructor:<br>
287998<br>
PyQt4.QtCore.QSize(-1, -1)<br>
Invalid device<br>
Invalid device<br>
PyQt4.QtCore.QSize(0, 0)<br>
<br>
<br>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div><br>