[PyQt] identify a QTreeWidgetItem
romanocaldoni at free.fr
Wed Oct 24 13:04:28 BST 2007
Le mardi 23 octobre 2007, Michael Towers a écrit :
> alteo_gange wrote:
> >> print item.text(0), "\n"
> >> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
> >> position 11: ordinal not in range(128)
> I find this one of the most annoying things in PyQt, it confuses me
> terribly. I think in this case you can do (for example)
> print unicode(item.text(0)), "\n"
> (the original result from item.text() being a QString)
> But it may be that you need to specify an encoding and use the
> encode or decode methods of unicode or string ...
Thanks! It works. Generally i write ' u"unicode characters" ', but in this
case it was impossible.
Moreover i forgot u"" in the next of my function:
> if item.text(0) == u"Filtres Vidéos"
More information about the PyQt