[PyQt] Variable
Boudewijn Rempt
boud at valdyas.org
Mon May 6 13:39:27 EDT 2002
Sebastian Roth wrote:
> [<qt.QString instance at 0x81f5424>, <qt.QString instance at 0x81fa464>]
>
But that's exactly what you've asked your script to do! All Qt widgets
return a QString object when you ask them for text. What you need to do, is
to convert the QString's to either unicode or string objects, using the
unicode() or str() functions:
ulist.insert(0,str(a))
ulist.insert(1,str(b))
(you are aware that you simply append to a list?)
Curiously enough, this same question has just appeared on the PyKDE
mailing list (which, despite its name) deals mainly with PyQt:
http://mats.gmd.de/mailman/listinfo/pykde
The PyQt documentation contains a short and clear statement on strings,
namely that Python unicode objects and strings are auto-converted to
QString objects when used in Qt method calls that expect a QString, but
that Qt objects always return a QString.
For a more complete treatment:
http://www.opendocspublishing.com/pyqt/index.lxp?lxpwrap=x2068%2ehtm
The rest of the chapter might be of interest to you, too :-).
--
Boudewijn Rempt | http://www.valdyas.org
More information about the Python-list
mailing list