Unsolved QTextView changes the HTML string
-
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 -
@moravas: or something else?
Keep the HTML contents in a QString variable :-)
-
Thank you!
I checked this idea, but what about when the user edit the content? I have to track it.
-
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. -
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 -
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. -
@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.