highlighter.h

来自「Qt4源代码,详细介绍了Qt4编程中的范例」· C头文件 代码 · 共 41 行

H
41
字号
#ifndef HIGHLIGHTER_H#define HIGHLIGHTER_H#include <QSyntaxHighlighter>#include <QHash>#include <QTextCharFormat>class QTextDocument;class Highlighter : public QSyntaxHighlighter{    Q_OBJECTpublic:    Highlighter(QTextDocument *parent = 0);protected:    void highlightBlock(const QString &text);private:    struct HighlightingRule    {        QRegExp pattern;        QTextCharFormat format;    };    QVector<HighlightingRule> highlightingRules;    QRegExp commentStartExpression;    QRegExp commentEndExpression;    QTextCharFormat keywordFormat;    QTextCharFormat classFormat;    QTextCharFormat singleLineCommentFormat;    QTextCharFormat multiLineCommentFormat;    QTextCharFormat quotationFormat;    QTextCharFormat functionFormat;};#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?