Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Syncing content between two qtextedits with undo history
Forum Updated to NodeBB v4.3 + New Features

Syncing content between two qtextedits with undo history

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sharmila
    wrote on last edited by
    #1

    I'm writing a cross-platform blog editor. My issue is this. There is a wysiwyg editor tab (with a QTextEdit) and a html code editor tab (again with a QTextEdit). They both should reflect the same blog content, only that they are in different modes. A change done in one should reflect in the other. One option is to use the setHtml and toHtml functions of the qtextedit objects whenever text changes in a qtextedit. But the issue with this approach is that when I use setHtml on a qtextedit, all the previous edit undo history is lost. If I try to maintain my own history on textchanged signal, lots of memory will be used. Consider I enter a sentence, textchanged will be signaled for every single character and undo would be character by character.

    I tried sharing the same qtextdocument between the two qtextedits but that also failed as highlighting is linked to the qtextdocument and hence is applied to both qtextedits.

    Another option is to do nothing when the user works in the wysiwyg editor window. When the user makes some edit in the html code editor, I'll wait till the user finishes the edit and then once done, I'll find the diff of the edit and somehow, make a corresponding edit change in the wysiwyg editor's qtextdocument. Is this achievable? How can I do such a change in the qtextdocument? Is there a more simple way that I am not aware of?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved