Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QTextView changes the HTML string

    General and Desktop
    html
    3
    7
    1250
    Loading More Posts
    • 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.
    • M
      moravas last edited by

      Hi Folks,

      I have a HTML producer module. The provided HTML contains lots of "metadata", like HTML class informations and more grouped into <span> tag. When I display this HTML in QTextEdit trough setHtml() then I acquire it back via toHtml(), these informations gone away.
      Can anybody help me, how can I avoid it? Can it turn off or something else?

      Regards,
      Norbert

      m.sue raven-worx 2 Replies Last reply Reply Quote 0
      • m.sue
        m.sue @moravas last edited by

        @moravas: or something else?

        Keep the HTML contents in a QString variable :-)

        1 Reply Last reply Reply Quote 0
        • M
          moravas last edited by

          Thank you!

          I checked this idea, but what about when the user edit the content? I have to track it.

          1 Reply Last reply Reply Quote 0
          • m.sue
            m.sue last edited by m.sue

            Yes, I only thought about the display, sorry. Then you will really need a way to switch it off.
            Are the vanishing data outside of the <body> tag? Then it would probably be easy to keep track.
            -Michael.

            1 Reply Last reply Reply Quote 0
            • M
              moravas last edited by moravas

              Hi,

              no, it is inside the body. Mainly, these data is class tags belongs to each word, like:

              <span class="meta word info">Hello</span> <span class="other meta word info">Word</span>
              

              while acquiring back the HTML seems like this:

              <span name="1">Hello</span> <span name="2">Word</span>
              

              so my original informations have been lost.

              Regards,
              Norbert

              1 Reply Last reply Reply Quote 0
              • m.sue
                m.sue last edited by m.sue

                Did you try the QTextBrowser class? The name sounds more promising in this context. Oops, no, its not editable!
                You will then probably have to use the QtWebEngine module. I do not have experience with it. Maybe someone else can tell you more.
                -Michael.

                1 Reply Last reply Reply Quote 0
                • raven-worx
                  raven-worx Moderators @moravas last edited by raven-worx

                  @moravas
                  QTextEdit and buddies only support rich-text and are not suitable for full HTML editing.
                  You should use either QtWebkit module or QtWebEngine (depending on the Qt version you are using) and set the contents editable.
                  But at least QtWebkit (and i guess also QtWebEngine) changes the content a little bit, but the HTML stays valid all the time at least.

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post