Instance of what?
Instance of a contactview http://github.com/drf/amsn2/blob/507...actlistview.py
contact.name is an instance of ContactView? What did you want to obtain by putting it into a QStandardItem?
No. contact is an instante of contactview. contact.name contains an html formatted text. I wan't to put that text into a QStandardItem.
edit: Maybe I dont explain myself well (sorry for my english)
contactview is an instance of contactview.
contact.name is an <class 'amsn2.core.views.stringview.StringView'>
(that's what I get from type(contact.name) )
Last edited by alexandernst; 26th July 2009 at 15:14.
So that's a StringView. You need to find a way to convert StringView to a string, then you can pass that to QString::fromUtf8().
QString(str(contact.name)) will add this to the QStandardItem, but I wont get the non-ascii symbols. Instead of that, I'll get... weard letters from the ascii table.
I have been looking the other front-end (the gtk one) (I'm working on the qt4 one) and the string there is assigned this way:
Qt Code:
self._model.set_value(citer, 2, common.escape_pango(str(contactview.name)))To copy to clipboard, switch view to plain text mode
and escape_pango is like this:
Qt Code:
def escape_pango(str): str = gobject.markup_escape_text(str) str = str.replace('\n',' ') return strTo copy to clipboard, switch view to plain text mode
So, I need to parse the html formatted contact.name string. What could I use? cgi.escape? Could you give me an example if that's the right one, please?
GTK doesn't use Unicode, so a conversion is not required. If you are getting "weird" characters here, then a conversion from utf-8 (or other appropriate encoding) is required.
Did you try this?
python Code:
QStandardItem(QString.fromUtf8(str(contact.name)));To copy to clipboard, switch view to plain text mode
Woow !! I think that's the only combination of "from*" and "str" that I didn't tried, and it works! Thank you wysota![]()
Bookmarks