QTextEdit real time html interpretation



  • Hello all,

    we are discussing in my team to implement a editor with runtime html preview function.
    basically there would be two view in the editor, one normal textedit, one for html edit.

    the target is, when the user works in the htmledit he could see the preview in the textedit in the real time. the problem is obviously the performance problem.

    so the issues could be, now on hand:

    1. partly update the text via any way to get only a piece of html text where it was updated. But qtextedit only gives me the whole html text via QTextEdit::toHtml().

    2. text cursor navigation. So when the html text is updated, in the text edit view, he should only update the certain text block or text frame and keep the text cursor stay in the current block, or in the current frame.

    anyone who could provide even some hints to implement it?

    Thank you.



  • Some hints:

    QTextDocument()
    QTextBlock()
    QTextCursor()



  • ...

    @NetZwerg

    so you provide me some "hints", let me trace those and guess what your hints probably help?

    the user edits the html editor and i know the current editing block sure. and what is the way to map this block to the corresponding block in the other view?



  • What about both have the same source or have an reference to that source. So if user changes in html editor a block (you can identify the block by cursor), you know which block the change was in. If both sources keep in sync you just need to apply the change in textedit at the same block-number or just replace the source-block in textedit by source-block from html-edit. Sounds good?

    Basicly you just throw blocks in between both views.

    Btw. you just requested some hints without telling us how far you got up to now. So my hints were perfectly valid.


Log in to reply
 

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