ok, how about
i) using a QItemDelegate in the QTreeWidget approach, too?
ii) pass Qt::TextWordWrap to QPainter::drawText
in YourItemDelegate:
aint(...):
I would not do the algorithm for drawing colored text myself (unless I had to, that is).
Doesn't a simple
painter->translate(option.rect.topLeft());
// if you want wrapping text
// doc.setTextWidth(option.rect.width());
QString text
=index.
data().
toString();
// assuming you can get the xml to display that way doc.setHtml(text);
doc.drawContents(painter);
painter->translate(option.rect.topLeft());
QTextDocument doc;
QSyntaxHighlighter yourHighlighter(&doc);
// if you want wrapping text
// doc.setTextWidth(option.rect.width());
QString text=index.data().toString(); // assuming you can get the xml to display that way
doc.setHtml(text);
doc.drawContents(painter);
To copy to clipboard, switch view to plain text mode
work for you?
(Maybe it is inefficient, but it is easy to implement. And maybe it is fast enough, too.
Bookmarks