Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt QSCINTILA突出显示匹配词_Qt_Qscintilla - Fatal编程技术网

Qt QSCINTILA突出显示匹配词

Qt QSCINTILA突出显示匹配词,qt,qscintilla,Qt,Qscintilla,我试图在编辑器上突出显示所有匹配的单词,但似乎不知道如何正确突出显示文本。我可以成功地循环所有找到的匹配项,但似乎找不到正确的调用来突出显示它。这是我的密码: bool found = true; while(found) { editor->getCursorPosition(&line, &index); qDebug() << "line: " << line << " index: " << i

我试图在编辑器上突出显示所有匹配的单词,但似乎不知道如何正确突出显示文本。我可以成功地循环所有找到的匹配项,但似乎找不到正确的调用来突出显示它。这是我的密码:

bool found = true;  

while(found)
{
    editor->getCursorPosition(&line, &index);

    qDebug() << "line: " << line << " index: " << index;

    found = editor->findFirst(pattern, use_regular_expression, is_case_sensitive, match_whole_word_only, use_wrap, search_forward);

    if(found)
    {
        int start = editor->positionFromLineIndex(line, index);
        int end = editor->positionFromLineIndex(line, index + pattern.length());

        qDebug() << "line: " << line << " start: " << start << " end: " << end;

        // Attempts to highlight
        editor->SendScintilla(QsciScintilla::SCI_INDICGETSTYLE, QsciScintilla::INDIC_BOX);
        editor->SendScintilla(QsciScintilla::SCI_INDICSETFORE, 0x007f00);
        //child[0]->SendScintilla(QsciScintilla::SCI_INDICATORFILLRANGE, start, end - start);
        editor->SendScintilla(QsciScintilla::SCI_INDICATORFILLRANGE, start, end - start);
        editor->setIndicatorForegroundColor(QColor(159, 144, 0));
      //  editor->setColor(QColor(159, 144, 0));**
    }
}
boolfound=true;
while(找到)
{
编辑器->获取光标位置(&行,&索引);
qDebug()你可以试试

SendScintilla(QsciScintillaBase::SCI_INDICSETSTYLE,0, INDIC_BOX);

QString docText = text();
int end = docText.lastIndexOf(findText);
int cur = -1; 

if(end != -1) {

   while(cur != end) {
        cur = docText.indexOf(findText,cur+1);`
        SendScintilla(QsciScintillaBase::SCI_INDICATORFILLRANGE,cur,
            findText.length());
   }
}