• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿
            #ifndef KEYWORD_HIGHLIGHTER_H
            #define KEYWORD_HIGHLIGHTER_H
            #include 
            <QSyntaxHighlighter>
            #include 
            <QTextCharFormat>
            #include 
            <QRegularExpression>
            #include 
            <QTextDocument>

            class KeyWordHighlighter final : public QSyntaxHighlighter
            {
                Q_OBJECT
            public:
                KeyWordHighlighter(QTextDocument
            * parent = nullptr);
                
            void setKeyWords(const QStringList& keywords);
            protected:
                
            void highlightBlock(const QString& text)override;
            private:
                
            struct HighlightingRule
                {
                    QRegularExpression pattern;
                    QTextCharFormat format;
                };

                QVector
            <HighlightingRule> highlightingRules;
                QTextCharFormat keywordFormat;
            };

            #include "KeyWordHighLighter.h"

            KeyWordHighlighter::KeyWordHighlighter(QTextDocument* parent):
            QSyntaxHighlighter(parent)
            {
            }

            void KeyWordHighlighter::setKeyWords(const QStringList& words)
            {
                HighlightingRule rule;

                keywordFormat.setForeground(Qt::black);
                keywordFormat.setFontWeight(QFont::Bold);

                foreach(auto word,words)
                {
                    rule.pattern = QRegularExpression(word);
                    rule.format = keywordFormat;
                    highlightingRules.append(rule);
                }
            }

            void KeyWordHighlighter::highlightBlock(const QString& text)
            {
                foreach(auto rule,highlightingRules)
                {
                    QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
                    while(matchIterator.hasNext())
                    {
                        QRegularExpressionMatch match = matchIterator.next();
                        setFormat(match.capturedStart(),match.capturedLength(),rule.format);
                    }
                }
            }
            posted on 2019-08-13 18:35 ccsdu2009 閱讀(515) 評論(0)  編輯 收藏 引用 所屬分類: QT編程
             
            国产∨亚洲V天堂无码久久久| 亚洲国产综合久久天堂| 97久久超碰成人精品网站| 97久久天天综合色天天综合色hd | 久久人人爽人人人人片av| 久久亚洲精品无码AV红樱桃| 亚洲一区中文字幕久久| 久久免费看黄a级毛片| 久久久91精品国产一区二区三区| 久久夜色精品国产| 91久久精一区二区三区大全| 91麻豆国产精品91久久久| 久久久久中文字幕| 久久久久AV综合网成人| 久久这里有精品| 久久精品国产一区二区| 99久久www免费人成精品| 久久人妻少妇嫩草AV无码专区| 日本精品久久久久影院日本| 国产A级毛片久久久精品毛片| 日韩AV无码久久一区二区| 亚洲精品美女久久久久99小说| 99久久www免费人成精品| 精品久久久久久久久中文字幕| 色偷偷久久一区二区三区| 中文国产成人精品久久不卡| 久久久久亚洲av成人无码电影| 99久久精品国产综合一区| 婷婷综合久久中文字幕| 97久久天天综合色天天综合色hd| 无码超乳爆乳中文字幕久久| 精品一二三区久久aaa片| 亚洲欧美一级久久精品| 亚洲精品无码久久久久AV麻豆| 久久国产美女免费观看精品| 久久国产亚洲精品麻豆| 亚洲嫩草影院久久精品| 99久久精品国产一区二区蜜芽 | 久久国产V一级毛多内射| 成人精品一区二区久久久| 亚洲乱亚洲乱淫久久|