Is there a way in which I could display an icon to a row in QTableView? I want to put an icon like I put to the QTableWidgetItem. The icon to be in the same cell with the text. Is that possible?
Thank you.
Is there a way in which I could display an icon to a row in QTableView? I want to put an icon like I put to the QTableWidgetItem. The icon to be in the same cell with the text. Is that possible?
Thank you.
Sure it's posible.
http://doc.trolltech.com/4.3/qtablew...m.html#setIcon
I want to set items icons in QTableView not QtableWidgetDo you know how I can do that?
Sorry, missunderstood your sentence.
I do it like so:
Qt Code:
QModelIndex pI; model->setData( pI, title, Qt::DisplayRole); model->item(itemCount, 0)->setEditable( false ); // Lot's of adding item+subitems code icon = setItemIcon(type, ownership);To copy to clipboard, switch view to plain text mode
setItemIcon() function is my own function in which I programaticaly choose which icon to use, and icon is a QString variable which contains strings like, ":/images/some_icon.xpm"
And I use QStandardItemModel for the item model. But I think this works on all items.
itemCount is the number to which row the icon should be assigned to and 0 is for the first column.
Thanks a lot, this solved my problemYou are great.
Bookmarks