[PyKDE] Little bug in QTextStream

Phil Thompson phil at riverbankcomputing.co.uk
Sat Oct 21 00:19:20 BST 2006


On Monday 16 October 2006 7:24 am, Simon Edwards wrote:
> Hi Phil,
>
> -------------------------
> #!/usr/bin/env python
>
> from PyQt4 import QtCore
>
> def main():
>
>     f = QtCore.QFile("Stream_test.txt")
>     f.open(QtCore.QIODevice.WriteOnly)
>
>     stream = QtCore.QTextStream(f)
>     num = 80
>     stream << "This is my number " << num << "."
>     f.close()
>
> main()
> ---------------------------
>
> Output is "This is my number 1.", while I had expected "This is my number
> 80.".

It's treating the int as a bool. PyQt has never supported basic types and 
QTextStream - but I've added limited support in the latest PyQt4 snapshot. 
There are easier ways to do this in standard Python.

Phil




More information about the PyQt mailing list