[PyKDE] PyQt: Something wrong with QTextStream.read()
Phil Thompson
phil at riverbankcomputing.co.uk
Sun Dec 19 00:27:18 GMT 2004
On Sunday 19 December 2004 12:14 am, Troy Melhase wrote:
> On Saturday 18 December 2004 02:55 pm, Parzival Herzog wrote:
> > 1 from qt import *
> > 2 woof = "WOOF\n"
> > 3 print woof
> > 4 woof_ts = QTextStream(woof, IO_ReadOnly)
> > 5 print woof
> > 6 rewoof = woof_ts.read()
> > 7 print rewoof
>
> Can you make the string a QByteArray? This works for me:
>
>
> from qt import *
> woof = QByteArray("WOOF\n")
> print woof
> woof_ts = QTextStream(woof, IO_ReadOnly)
> print woof
> rewoof = woof_ts.read()
> print rewoof
Yes - or a QString.
In the original code a temporary QString is being created under the covers (to
hold the converted Python string) which is then being destroyed.
Phil
More information about the PyQt
mailing list