在帮助手册(Qt Assist)中,关于这个函数有更详尽的描述并附带一个例子: “Highlights the given text block. This function is called when necessary by the rich text engine, i.e. on text blocks which have changed. 高亮给出的文本块。这个函数会在需要的时候被rich text引擎调用,比如在文本块有改动时。 To provide your own syntax highlighting, you must subclass QSyntaxHighlighter and reimplement highlightBlock(). In your reimplementation you should parse the block's text and call setFormat() as often as necessary to apply any font and color changes that you require. 为了提供你定义的高亮规则,你必须继承QSyntaxHighlighter,并重新实现highlightBlock()。在你的重新实现中,你应该解析指定块中的文本,并在需要时调用setFormat()来应用你需要的字体和颜色的改变。 “ 关于这个函数和示例的详细描述,可以参考帮助文档。