Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QWebFrame original HTML for WYSIWYG editor
Hi! I'm trying to develop an html editor. The document can be modified through a QWebPage and through a text editor:
I do this to update the text editor content when the user modify the QWebPage:
@ QString a = QWepPage::mainFrame()->toHtml() ;
The problem is that toHtml() method return a processed html string where some characters are replaced. The user doesn't want this, only the user's changes should be visible. I thought to use the unprocessed string of the QWebFramePrivate, but it is private. I could also save the original text and add the differences of QWepPage::mainFrame()->toHtml() to it, but I can't distinguish user's modifications
Did I understand you correctly? You want to allow the user to edit the HTML inside the QWebView (contentEditable) and inside your own texteditor ? Because I would suggest you allow either the first OR the second, that would make life a whole lot easier for you ^^.
EDIT: Maybe this link will help "WYSIWYG editor":http://labs.qt.nokia.com/2009/03/12/wysiwyg-html-editor/
bq. that would make life a whole lot easier for you
I know, but it would be nice to edit both in the same time :)
unfortunately the git rep of that project is unavailable
EDIT: yes, you understand me correctly
Try this link: "HTMLEditor":http://qt.gitorious.org/qt-labs/graphics-dojo/trees/master/htmleditor
I'm not sure it's the one (I got it directly next to the other link in my bookmarks)
yes, it is, thank you.
but the plaintextedit of that project is readonly, you can modify the source only through the webview.
Keep me posted about your progress as I'm really curious how you will solve this.
And may the force be with you ;-)
so, It seems the only possible thing to do is to access the QWebFramePrivate member of QWebFrame, anyone know how is it possible?
there's also a way to make this work, but it's expansive.
- save the text of the editor in QString a, open with QWebFrame and QString b = toHtml()
- once the user modified the document save another time toHtml() to QString c
- find difference between b and c, character by character, and apply them to a.
I'm not going to use this method, I hope somehow the QWebFramePrivate could be accessed to use it's
I once had to use a private function from a class I had no way of changing for my needs. I found a way to use that private function by making a new class derived from the class whose private function I wanted to use. It was in no way safe or good programming style but it worked for me. Since I luckily found a workaround for my problem I removed that later and forgot about it.
I suggest you create a new thread asking for a way to access a private member from one of the Qt classes. Something like "How to access the private member QWebFramePrivate of QWebFrame".
Sry I can't help you.
ok, thank you anyway. I'm going to open another thread
luisvt last edited by
How can I acces to de CSS data from the QWebView. I mean, I know that I can edit the styles using the QInspector, but I want to save the editions after editing with the inspector. How could I do that?