On 2010-04-27, Hugo Parente Lima wrote:
> On Tuesday 27 April 2010 04:32:17 Mark Summerfield wrote:
> > (...)
> > I think there's confusion here between QTextStream and QDataStream. I
> > personally haven't looked at QTextStream since I can't see any reason to
> > use it compared with Python's own facilities. However, QDataStream is a
> > different matter since that makes it possible to read/write formats that
> > can be read/written by C++/Qt programs, so getting it right is
> > important.
> 
> You can write on QIODevices using QTextStream, but you can also do it
>  without QTextStream, hehehe, so it's useless.

Well, it isn't completely useless:-) I don't think you can set an
encoding directly on a QIODevice, but you can on a QTextStream.

So:

    QFile fh(filename)
    if fh.open(...):
        QTextStream in(fh)
        in.setCodec("utf-8")

vs.

    QFile fh(filename)
    if fh.open(...):
        text = fh.readAll() # what encoding is read? probably local 8-bit?

But for Python it does seem that using codecs in Python 2 and open in
Python 3 gives you all you need to read & write text. So only
QDataStream really needs to be supported by PySide. (Unless PySide is
used for C++/Qt prototyping.)


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Programming in Python 3 (Second Edition)" - ISBN 0321680561
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to