A simpler approach to your problem would be as follows -
For the listWidgetItem, use setData to store the result in your defined role, say RESULT_ROLE.
Now use a custom delegate and override the drawDisplay as follows -
MyDelegate::drawDisplay(......)
{
QString result
= text;
// text is the argument string to draw if(option.state & Qt::Selected) // if item is selected...
result = index.data(RESULT_ROLE);
QItemDelegate::drawDisplay(result....
);
// use result instead of text }
MyDelegate::drawDisplay(......)
{
QString result = text; // text is the argument string to draw
if(option.state & Qt::Selected) // if item is selected...
result = index.data(RESULT_ROLE);
QItemDelegate::drawDisplay(result....); // use result instead of text
}
To copy to clipboard, switch view to plain text mode
Hope this works for you
Bookmarks