Results 1 to 3 of 3

Thread: [PyQt] displaying icon and text in one QListWidgetItem on QListWidget

  1. #1
    Join Date
    Jul 2009
    Posts
    14
    Thanks
    1
    Qt products
    Platforms
    MacOS X Windows

    Default [PyQt] displaying icon and text in one QListWidgetItem on QListWidget

    I am currently implementing an instant messenger called Pendulim written in Python using PyQt4,
    and I am having a trouble with displaying emoticons and text in one line on
    chat window.

    I am using QListWidget to display conversations and each line as
    QListWidgetItem. the trouble is that i cannot add or append QListWidgetItem,
    so I can't combine emoticon and string.

    this is a chatwindow class.
    http://code.google.com/p/pendulim/so.../ChatWindow.py

    for example:
    Qt Code:
    1. item = QtGui.QListWidgetItem(self.convoWindow)
    2. emoticon = QtGui.QListWidgetItem(self.convoWindow)
    3. icon = QtGui.QIcon()
    4. icon.addPixmap(QtGui.QPixmap(path), QtGui.QIcon.Normal, QtGui.QIcon.Off)
    5. emoticon.setIcon(icon)
    6. item.setText(some_string)
    7. #here i would like to combine item and emoticon so that I can display it in
    8. one line
    To copy to clipboard, switch view to plain text mode 

    Is there any way to display icon and string in one QListWidgetItem? or is
    there any alternative way to meet the need?
    I would very appreciate if you could give me any kind of help.
    thank you for consideration.

    Best regards

    Naoya Makino
    Last edited by naoyamakino; 14th July 2009 at 23:32.

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

    Default Re: [PyQt] displaying icon and text in one QListWidgetItem on QListWidget

    What is the effect you obtain? The code you have shown looks correct and should work fine.
    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.


  3. #3
    Join Date
    Jul 2009
    Posts
    14
    Thanks
    1
    Qt products
    Platforms
    MacOS X Windows

    Default Re: [PyQt] displaying icon and text in one QListWidgetItem on QListWidget

    hi wysota, your reply on another post solved a problem. the effect I was getting here was that text and emoticons are in the different lines. the code works fine, but I needed to show emoticons and text in the same line. so i decided to use QTextedit instead.

    for a reference, here is the another post that has a solution to display emoticon and text showing in one line (not using QListWidgetItem)

    How to display image on QPlainTextEdit

    regards

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.