Hi.
I have a QTextEdit subclass coupled with a QSyntaxHighlighter. After the syntax is highlighted I try to get the char format and the text under a certain position. The text returns correctly, but the format I get seems to be the the default format and not the format I set on the highlighter at this position.
This is the code:
{
if (format != NULL)
{
*format = cursor.charFormat();
}
QString rc
= cursor.
selectedText();
cursor.clearSelection();
return rc;
}
QString LineTextEdit::getTextAndPropertyAtPosition( const QPoint & pos, QTextCharFormat *format)
{
QTextCursor cursor = cursorForPosition(pos);
cursor.select(QTextCursor::WordUnderCursor);
if (format != NULL)
{
*format = cursor.charFormat();
}
QString rc = cursor.selectedText();
cursor.clearSelection();
return rc;
}
To copy to clipboard, switch view to plain text mode
Bookmarks