[Qt-interest] WYSIWYG editing support in QWebView?

Lucas Maynes lucas.maynes at gmail.com
Tue Feb 17 21:00:22 CET 2009


I'll try to be as detailed as possible.

I'm trying to write a WYSIWYG XHTML editor in Qt. I need a modern 
renderer for the WYSIWYG display, so I can't use QTextEdit (I need 
support for external CSS files, advanced HTML, etc).

I initially approached Qt for this project because it has Webkit 
integrated. QWebView displays the kind of files I want nicely. But, I 
can't seem to figure out how to use QWebView for a WYSIWYG view. The only 
way I can get the blinking cursor is if I use the “contenteditable” 
attribute on, say, the body tag. While this does give me the cursor, it 
doesn't provide me with a way to query the cursor's position in the tag 
hierarchy or even in the character stream. It also does not seem to be 
the correct way of going about this. I basically need four things:

1. The ability to display a blinking cursor to the user.
2. The ability to retrieve that cursor's position.
3. The ability to insert characters at that position.
4. The ability to replace the characters inside the mouse selection.

That's pretty much it, since these are the most basic tools. While it 
would be nice to have the text editing features of QTextEdit with the 
display capabilities of QWebView in a single widget (if this can be done, 
please say how), I can do the rest myself if I have to.

Furthermore, the Webkit website has a section describing their support 
for HTML editing (http://webkit.org/projects/editing/index.html). They 
explicitly state there is some sort of embedded functionality, and 
browsing through the Webkit source code in “root/trunk/WebCore/editing”, 
there does appear to be something like that present. Looking through the 
Qt source, this code appears to be both present and included in the 
build. But how does one access that functionality? I'm not sure if this 
pertains to my main problem, but it does at least look like something 
that could come in handy. 

I've been burning through the Qt documentation, this mailing list's 
archive and your friendly neighborhood search engines on this for a good 
two weeks, and I can't figure it out. I'm stuck, and so I'm asking here, 
hoping for some clue as to how to accomplish this. As I've said, I'm very 
new to Qt, so if what I'm asking for is trivially simple to accomplish, 
please forgive my ignorance in advance, and kindly help out a poor soul.

Sincerely,

Lucas Maynes



More information about the Qt-interest-old mailing list