[Qt-interest] Change default background color for search results (QPlainTextEdit)
Jaco Naude
naude.jaco at gmail.com
Tue Mar 29 16:25:08 CEST 2011
I had the same problem. I have to say that its probably not the best
solution, but I keep a list of highlighted words and remove their formatting
before doing a new search. However this gets slow when you type and the
document is big. I know there must be a better way since Creator does
something similar much faster.
On Tue, Mar 29, 2011 at 10:43 AM, NoRulez <norulez at me.com> wrote:
> 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
>
>
>
>
>
> _______________________________________________
> 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/9f55d522/attachment.html
More information about the Qt-interest-old
mailing list