[Qt-interest] Fwd: QWebView for document editing

Nathan Carter nathancarter5 at gmail.com
Sat Jul 11 15:58:23 CEST 2009



>> - Decoration: Ideally I would like to paint an overlay to show
>> metainformation concerning the "document" (e.g. current node
>> selected). To do so would require knowledge of a bounding box for any
>> given node in my "document"'s model. Following from the previous
>> example, something like QRect QWebPage::boundingBox(void* _id) const;
>> would be good for me.
>
> Javascript in the web view can get this information for you.  Google  
> stuff like offsetLeft, offsetWidth, etc. as HTMLElement properties.   
> I haven't used this myself, I just know it exists.  You have to be  
> careful with taking scrolling into account, too.

I just thought of one other thing:  You can also use Javascript in the  
web view to do the highlighting, rather than paint an overlay.  Just  
set the style of the <span> you care about to a simple background  
highlighting using inline CSS.

The webview comes with all this Javascript power built in, so it's  
good to use it rather than try to write C++ code that can't really be  
as precise as the JS, because unlike the JS, it has no DOM API to  
access.

Unless you want the C++ API, which is still in development and thus  
maybe can be gotten from gitorious??  Not sure; check the article  
below.  (Scheduled for 4.6 release.)
http://labs.trolltech.com/blogs/2009/04/07/qwebelement-sees-the-light-do-i-hear-a-booyakasha/

Nathan




More information about the Qt-interest-old mailing list