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:
    http://img31.imageshack.us/img31/8369/26566672.png

    I do this to update the text editor content when the user modify the QWebPage:
    @ QString a = QWepPage::mainFrame()->toHtml() ;
    testEditor.setContent(a);
    @
    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.
    I was thinking to insert javascript code (invisible to user) to print the source code, the browser will read the printed code and send it to textEditor



  • 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.

    1. save the text of the editor in QString a, open with QWebFrame and QString b = toHtml()
    2. once the user modified the document save another time toHtml() to QString c
    3. 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
    QWebFramePrivate::frame->document() function



  • 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



  • 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?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.