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:
Qt Code:
  1. QString LineTextEdit::getTextAndPropertyAtPosition( const QPoint & pos, QTextCharFormat *format)
  2. {
  3. QTextCursor cursor = cursorForPosition(pos);
  4. cursor.select(QTextCursor::WordUnderCursor);
  5. if (format != NULL)
  6. {
  7. *format = cursor.charFormat();
  8. }
  9. QString rc = cursor.selectedText();
  10. cursor.clearSelection();
  11. return rc;
  12. }
To copy to clipboard, switch view to plain text mode