[Qt-interest] Retrieving QTextCharFormat a QSyntaxHighlighter sets
Wilhelm
wilhelm.meier at fh-kl.de
Sat Jun 11 22:51:11 CEST 2011
Hi all,
a QSyntaxHighlighter uses QTextLayout::setAddtionalFormats() to format
the text.
I tried to read back this format-information from the text-blocks, e.g.:
QList<QTextLayout::FormatRange> list;
for(QTextBlock::iterator it = block.begin(); it != block.end(); ++it) {
QTextFragment fragment = it.fragment();
if (fragment.isValid()) {
QTextLayout::FormatRange fr;
fr.format = fragment.charFormat();
fr.start = fragment.position() - currentBlock().position();
fr.length = fragment.length();
list.append(fr);
qDebug() << fr.start << fr.length << fr.format.foreground();
}
}
but with no luck. If the highlighter sets e.g. the foreground to a
special color, I can't read that back.
What's wrong?
--
Wilhelm
More information about the Qt-interest-old
mailing list