[PyQt] QTextstream >>
Chris Pezley
chris.pezley at quantumwise.com
Tue Jun 20 10:03:14 BST 2017
On 06/19/2017 05:36 PM, Christopher Probst wrote:
> Hi,
>
> I am loving the PyQt. I want to confirm that the operator ">>"
> QTextStream operator does not work in PyQt5. This will not work:
> file = QFile("myfile.txt")
>
> if file.open(QIODevice.ReadOnly):
> stream = QTextStream(file)
> stream >>value
> stream >> text >>value
> What are the preferred ways to deserialize an QIODevice in PyQt?
>
> Thanks,
> Christopher
The rrshift and rlshift operators won't work like that with QTextStream, no.
I would go with using python's build in functionality for files instead:
with open("myfile.txt", "r") as my_file:
value = my_file.read()
See the python documentation for more:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170620/460bf225/attachment.html>
More information about the PyQt
mailing list