Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
1.2.x
-
Windows
-
ca806b438e8a27dc4562ac806d189765e93e09e5
Description
from that question:
I am trying to subclass QFile in PySide to implement custom read behavior. However, as seen in the simplified code below, even if the subclass' readData implementation just calls the parent's readData function, the returned data is incorrect. Subclassing other QIODevices such as QBuffer also causes incorrect return values. Has anyone successfully subclassed a QIODevice?
from PySide import QtCore class FileChild1(QtCore.QFile): pass class FileChild2(QtCore.QFile): def readData(self, maxlen): return super(FileChild2, self).readData(maxlen) f1 = FileChild1('test.txt') f1.open(QtCore.QIODevice.ReadWrite|QtCore.QIODevice.Truncate) f1.write('Test text for testing') f1.seek(0) print 'FileChild1: ', repr(f1.read(50)) f2 = FileChild2('test2.txt') f2.open(QtCore.QIODevice.ReadWrite|QtCore.QIODevice.Truncate) f2.write('Test text for testing') f2.seek(0) print 'FileChild2: ', repr(f2.read(50)) >>> FileChild1: PySide.QtCore.QByteArray('Test text for testing') >>> FileChild2: PySide.QtCore.QByteArray('─ Q ►│A☻ @ p¼a☻Test text for testing\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
Attachments
Issue Links
- links to