Results 1 to 18 of 18

Thread: UTF8 and QStandardItem?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    125
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    16

    Default Re: UTF8 and QStandardItem?

    Sure

    giter.child(self._model.indexFromItem(citer).row() , 2).setText(QString.fromUtf8(contact.name))

    That the line. giter is the parent if the QStandrdItem (the child is QStandardItem too). I try to add the text in the 3rd column (index 2). The contact.name is passed to the def.

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

    Default Re: UTF8 and QStandardItem?

    I have to say that

    giter.child(self._model.indexFromItem(citer).row() , 2).setText(QString.fromUtf8(str(contact.name)))

    will add the text, so the problem is the encoding (¿?)

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

    Default Re: UTF8 and QStandardItem?

    How is contact.name defined? How did data end up in it?
    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
    Posts
    125
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    16

    Default Re: UTF8 and QStandardItem?

    I have been reading since yesterday, and I think I'm really confused. The answer of "what is contact" and "how is contact.name defined" is not that easy.

    contact.name is a strigview, defined in amsn2's <class 'amsn2.core.views.stringview.StringView'>

    edit: so, stringview is actualy an html formatted string.

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

    Default Re: UTF8 and QStandardItem?

    I'm not asking about the content, I'm asking about the object class itself. What does type() return on contact.name?
    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
    Posts
    125
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    16

    Default Re: UTF8 and QStandardItem?

    It's an instance.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    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.


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

    Default Re: UTF8 and QStandardItem?


  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    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.


  10. #10
    Join Date
    Jul 2009
    Posts
    125
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    16

    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.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    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.


  12. #12
    Join Date
    Jul 2009
    Posts
    125
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    16

    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?

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.