[Qt-interest] Change default background color for search results (QPlainTextEdit)

Jaco Naude naude.jaco at gmail.com
Tue Mar 29 12:38:58 CEST 2011


Oops, forgot to mention you need to set the text cursor again at the end:

setTextCursor(cursor);

On Tue, Mar 29, 2011 at 10:37 AM, Jaco Naude <naude.jaco at gmail.com> wrote:

> Maybe something like this:
>
> QTextCursor find_cursor = document()->find(search_string,textCursor());
> QTextCharFormat format(find_cursor.charFormat());
> format.setBackground(QBrush(Qt::green);
> find_cursor.mergeCharFormat(format);
>
> I've used something like this to highlight specific words in a class which
> inherits QPlainTextEdit.
>
> Hope it helps,
> Cheers
>
>
>
> On Tue, Mar 29, 2011 at 10:13 AM, NoRulez <norulez at me.com> wrote:
>
>> Hi,
>>
>>
>>
>> if I use „QPlainTextEdit::find(searchText, searchFlags)” then the search
>> results have a gray background.
>>
>> Is there a simple way to tell QPlainTextEdit, to use an alternative color,
>> such as green, orange, yellow, ...
>>
>>
>>
>> Thanks in advance
>>
>>
>>
>> Best Regards
>>
>> NoRulez
>>
>>
>>
>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110329/c36585a8/attachment.html 


More information about the Qt-interest-old mailing list