[PyQt] QIODevice+QImageReader oddity ?
Attila Csipa
pyqt at csipa.in.rs
Tue Apr 21 17:03:55 BST 2009
Hello, I'm fairly new to PyQt (have been using Qt from good old C++
previously) and have a strange issue I did not find a solution to in the
docs or the archives. In the code snippet below, the image reader works
if I specify the filename constructor, but not when I try to use it via
an QIODevice (like QFile or QBuffer). I'm on Ubuntu 9.04, using PyQt
4.4.4-2 with Qt 4.5.0-0 (these are the Ubuntu defaults). Am I missing
something trivial or is this a known issue ? Thanks in advance.
from PyQt4.QtGui import *
from PyQt4.QtCore import *
def chkerror(reader):
if reader.error():
print reader.errorString()
iod = QFile("poster_100hours.jpg")
print iod.size()
#reader = QImageReader("poster_100hours.jpg")
#reader = QImageReader()
reader = QImageReader(iod)
#reader.setDevice(iod)
chkerror(reader)
print reader.size()
chkerror(reader)
img = reader.read()
chkerror(reader)
print img.size()
----
with filename constructor:
287998
PyQt4.QtCore.QSize(1280, 1811)
PyQt4.QtCore.QSize(1280, 1811)
with QFile iodevice constructor:
287998
PyQt4.QtCore.QSize(-1, -1)
Invalid device
Invalid device
PyQt4.QtCore.QSize(0, 0)
More information about the PyQt
mailing list