[Qt-interest] QWebView inactive highlighted text color background
Strahinja Markovic
strahinja.markovic at gmail.com
Tue Nov 17 23:20:42 CET 2009
Hi,
I was wondering what would be the best way to change the background color of
the selected text highlight in QWebView when the window is inactive?
Let me elaborate...
I'm using a (sub-classed) QWebView as a WYSIWYG editor component, and I've
now mostly implemented a find&replace dialog. Now the dialog is a separate,
non-modal window that can control the QWebView. I have managed to
successfully select the searched-for text with JavaScript, but since the
QWebView is in a separate window which is inactive, the text is highlighted
in a very light gray color. It's barely distinguishable from the white
background.
Now if I switch the focus back to the main window, the highlight is that
nice blue color again. But I don't want the main window to have focus. I
want the find&replace dialog to keep it so the user can continue pressing
<Enter> with the "Find Next" button selected.
So I'm wondering how I could change that inactive selected text background
color. I've already tried using a custom QPalette, but QWebView ignores
this. I've read this can happen.
I was thinking of getting the size of the dimensions of the highlighted
rectangle and painting over that, but I don't know how to get those
dimensions. It also seems like overkill, but I'd be willing to try it.
I know I could do this by temporarily changing the underlying HTML and
inserting some highlighting CSS + <span>, but that's the last thing I'm
willing to try. I _really_ don't want to mess with the user's code.
Does anyone have any ideas?
Thanks in advance,
Strahinja Markovic
More information about the Qt-interest-old
mailing list