Hi wysota, thank you for the idea. and I am very close!!I switched QTextEdit to QListView and now I can select an item, display with icons;
def __init__(self,buddyList, parent=None):
self.buddyList = buddyList
def insert(self, name):
path = "image/icons/Messenger_blue32.png"
item.setEditable(False)
self.iStandardModel.appendRow(item)
self.setModel(self.iStandardModel)
class ContactsView(QtGui.QListView):
def __init__(self,buddyList, parent=None):
QtGui.QListView.__init__(self, parent)
self.buddyList = buddyList
self.iStandardModel =QtGui.QStandardItemModel(self)
def insert(self, name):
path = "image/icons/Messenger_blue32.png"
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(path), QtGui.QIcon.Normal, QtGui.QIcon.Off)
item = QtGui.QStandardItem(icon,name)
item.setEditable(False)
self.iStandardModel.appendRow(item)
self.setModel(self.iStandardModel)
To copy to clipboard, switch view to plain text mode
but I'm facing a same issue; I can't still find a way to get a selected QStandardItem...
there is a isSelectable function but I could not find things like isSelected().
I tried something like this:
self.contactList = ContactsView.ContactsView(self,self)
if(buddyList is not None):
for name in buddyList:
self.contactList.insert(name)
self.connect(self.contactList.selectionModel(),
QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"),
self.slot)
...
def slot(self, selected, deselected):
print str(selected), "items selected"
self.contactList = ContactsView.ContactsView(self,self)
if(buddyList is not None):
for name in buddyList:
self.contactList.insert(name)
self.connect(self.contactList.selectionModel(),
QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"),
self.slot)
...
def slot(self, selected, deselected):
print str(selected), "items selected"
To copy to clipboard, switch view to plain text mode
but this dose not print any useful information:
<PyQt4.QtGui.QItemSelection object at 0x03A77810> items selected
this prints out which ever I choose an item.
Could you please give me an advise again?
I very much appreciate your kindness and support.
regards
Naoya
Bookmarks