QTextView changes the HTML string
-
wrote on 12 Jan 2017, 06:34 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 -
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 -
wrote on 12 Jan 2017, 07:33 last edited by
Thank you!
I checked this idea, but what about when the user edit the content? I have to track it.
-
wrote on 12 Jan 2017, 07:47 last edited by m.sue 1 Dec 2017, 07:47
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. -
wrote on 12 Jan 2017, 08:34 last edited by moravas 1 Dec 2017, 08:35
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 -
wrote on 12 Jan 2017, 08:37 last edited by m.sue 1 Dec 2017, 08:48
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. -
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,
NorbertModeratorswrote on 12 Jan 2017, 08:41 last edited by raven-worx 1 Dec 2017, 08:41@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.
1/7