[Qt-interest] QWebElement containing the caret?

Terrence cert192 at googlemail.com
Sun Oct 25 18:01:27 CET 2009


Hi,

I'm using the "contentEditable" webkit option to make a WYSIWYG
editor. I'd like to use the new DOM API in Qt 4.6 to manipulate the
document. I'm trying to find the QWebElement that currently contains
the caret, but I can't see any way to do this. I would have thought
that this is a common use case.

I've tried iterating through all elements in the document and calling
QWebElement::hasFocus(), but that never returns true. However, I think
that this isn't quite what I want anyway, because I may want to know
where the caret is even when the webview doesn't have focus (for
example: if the user is clicking a toolbar button to perform an
operation on the element that contains the caret.)

Is there some way to get the QWebElement containing the caret? The DOM
API looks great, but it's frustrating that I can't access its power!
Alternatively is there some workaround? Perhaps using javascript to
find the element containing the caret, then somehow converting this to
a QWebElement (yep, this would be a hack, but it might just be
sufficient for the moment!).

Thanks

Terrence



More information about the Qt-interest-old mailing list