[PyQt] PyQt4 Python File Object to QFile
russ at coldstonelabs.org
Fri Feb 12 19:39:34 GMT 2010
David Boddie wrote:
> On Fri Feb 12 06:55:21 GMT 2010, Russell Valentine wrote:
>> I wonder if anyone ever bridged the gap between QFile and the Python
>> File Object? It could be handy sometimes to go between the two.
>> f is a python file object but, how can I use this in Qt? I realize I
>> could save it to some temp file and reopen it with QFile but that seems
> Try this:
> f = open(...)
> qt_f = QFile()
> qt_f.open(f.fileno(), QFile.ReadOnly)
Thank you for your reply. I had thought that there are some non-posix
systems where fileno doesn't work. I tried it in Linux and Windows.
Seems to work in Linux, but not in Windows. So it looks like it is a
good solution for posix systems at least.
More information about the PyQt