Results 1 to 18 of 18

Thread: UTF8 and QStandardItem?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: UTF8 and QStandardItem?

    Instance of what?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: UTF8 and QStandardItem?


  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: UTF8 and QStandardItem?

    contact.name is an instance of ContactView? What did you want to obtain by putting it into a QStandardItem?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: UTF8 and 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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: UTF8 and QStandardItem?

    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().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: UTF8 and QStandardItem?

    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:
    1. 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:
    1. def escape_pango(str):
    2. str = gobject.markup_escape_text(str)
    3. str = str.replace('\n',' ')
    4. return str
    To 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?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: UTF8 and QStandardItem?

    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:
    1. QStandardItem(QString.fromUtf8(str(contact.name)));
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: UTF8 and QStandardItem?

    Woow !! I think that's the only combination of "from*" and "str" that I didn't tried, and it works! Thank you wysota

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.