Hi,

I'm trying to change the indentation of text with the QSyntaxHighlighter, but so far I found no solution. It's easy to change the color or the fontweight but it is also possible to change the indentation? I want to indent comments in my QTextEdit.

Thank you for any suggestions.
Fred

Qt Code:
  1. void MyHighlighter::highlightBlock(const QString &text)
  2. {
  3. QTextCharFormat myClassFormat;
  4. myClassFormat.setFontWeight(QFont::Bold);
  5. myClassFormat.setForeground(Qt::darkMagenta);
  6. QString pattern = "\\bMy[A-Za-z]+\\b";
  7.  
  8. QRegExp expression(pattern);
  9. int index = text.indexOf(expression);
  10. while (index >= 0) {
  11. int length = expression.matchedLength();
  12. setFormat(index, length, myClassFormat);
  13. index = text.indexOf(expression, index + length);
  14. }
  15. }
To copy to clipboard, switch view to plain text mode