i have simple item delegate from QStyledItemDelegate type inside its paint method i have this code . it renders fine , but the main thing here that i like the text to be
selectable for copy , and this dosn't work .
void ItemDelegate
::paintBody( QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index ) const {
painter->save();
l->setTextFormat(Qt::RichText);
l->setTextInteractionFlags(Qt::TextSelectableByMouse);
l->setGeometry(option.rect);
l->setText("This is test");
l->setStyleSheet("QLabel { background-color : transparent; }");
l->render(painter, option.rect.topLeft());
painter->restore();
}
void ItemDelegate::paintBody( QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index ) const {
painter->save();
QLabel *l = new QLabel();
l->setTextFormat(Qt::RichText);
l->setTextInteractionFlags(Qt::TextSelectableByMouse);
l->setGeometry(option.rect);
l->setText("This is test");
l->setStyleSheet("QLabel { background-color : transparent; }");
l->render(painter, option.rect.topLeft());
painter->restore();
}
To copy to clipboard, switch view to plain text mode
Bookmarks