[PyQt] Converting to API 2
Mark Summerfield
list at qtrac.plus.com
Thu Apr 22 08:53:36 BST 2010
Hi,
I'm starting to convert the examples from my PyQt book to Python 3 with
API 2. Perhaps I'm not awake yet, but I'm puzzled by this:
Python 3.1.2 (r312:79147, Mar 25 2010, 07:42:02)
[GCC 4.4.1] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> from PyQt4.QtCore import *
>>> from PyQt4.QtGui import *
>>> PYQT_VERSION_STR
'4.7.3'
>>> QT_VERSION_STR
'4.6.1'
>>> fh = QFile("/tmp/data")
>>> fh.open(QIODevice.WriteOnly)
True
>>> out = QDataStream(fh)
>>> out.writeString("hello")
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
out.writeString("hello")
TypeError: QDataStream.writeString(str): argument 1 has unexpected type
'str'
And also by this:
>>> fh = QFile("/tmp/data")
>>> fh.open(QIODevice.WriteOnly)
True
>>> out = QDataStream(fh)
>>> out << "hello"
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
out << "hello"
ValueError: string of length 1 expected
What am I missing here?
--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Programming in Python 3 (Second Edition)" - ISBN 0321680561
More information about the PyQt
mailing list