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

NoRulez norulez at me.com
Tue Mar 29 12:43:44 CEST 2011


But the problem is, that if I merge the char format
(find_cursor.mergeCharFormat(format)), then I can’t remove the format if I
search for a different text

 

Best Regards

 

Von: Jaco Naude [mailto:naude.jaco at gmail.com] 
Gesendet: Dienstag, 29. März 2011 12:39
An: NoRulez
Cc: qt-interest at qt.nokia.com
Betreff: Re: [Qt-interest] Change default background color for search
results (QPlainTextEdit)

 

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/23264057/attachment.html 


More information about the Qt-interest-old mailing list