<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[solved] Getting source from QWebView]]></title><description><![CDATA[<p dir="auto">Hello<br />
When loading a page into a QWebView</p>
<p dir="auto">@ui-&gt;webView-&gt;load(QUrl("<a href="http://www.google.com" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.google.com</a>"));@</p>
<p dir="auto">How can I get the source code (html) of the page? I can't retrieve the site directly,<br />
because I might have browsed forward from the loaded site before I want to display the source.<br />
E.g. having a textedit below the qwebview that shows the source of the current site while I browse<br />
in the qwebview, kinda like</p>
<p dir="auto">@ui-&gt;textEdit-&gt;setText(ui-&gt;webView-&gt;getSource()); (which naturally doesn't work...)@</p>
<p dir="auto">Thank you. Best regards<br />
Richard Salin</p>
]]></description><link>https://forum.qt.io/topic/15369/solved-getting-source-from-qwebview</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 13:03:55 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/15369.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Mar 2012 08:14:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [solved] Getting source from QWebView on Tue, 27 Mar 2012 09:00:06 GMT]]></title><description><![CDATA[<p dir="auto">The setPlainText did the trick. Thank you!<br />
Best regards<br />
Richard</p>
]]></description><link>https://forum.qt.io/post/133734</link><guid isPermaLink="true">https://forum.qt.io/post/133734</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 27 Mar 2012 09:00:06 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] Getting source from QWebView on Tue, 27 Mar 2012 08:50:16 GMT]]></title><description><![CDATA[<p dir="auto">try this: @ui-&gt;webView-&gt;page()-&gt;currentFrame()-&gt;documentElement().toOuterXml()@</p>
<p dir="auto">also to avoid QTextEdit from trying to guess the format of the text you're handing over you better use setPlainText() instead of setText() as suggested in the "documentation":<a href="https://qt-project.org/doc/qt-4.8/qtextedit.html#setText" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-4.8/qtextedit.html#setText</a>.</p>
<p dir="auto">@ui-&gt;textEdit-&gt;setPlainText(ui-&gt;webView-&gt;page()-&gt;currentFrame()-&gt;toHtml());@</p>
]]></description><link>https://forum.qt.io/post/133732</link><guid isPermaLink="true">https://forum.qt.io/post/133732</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 27 Mar 2012 08:50:16 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] Getting source from QWebView on Tue, 27 Mar 2012 08:42:18 GMT]]></title><description><![CDATA[<p dir="auto">Thanks. One more thing, how can I display it in the TextEdit? Iif I try the following:</p>
<p dir="auto">@ui-&gt;textEdit-&gt;setText(ui-&gt;webView-&gt;page()-&gt;currentFrame()-&gt;toHtml());@</p>
<p dir="auto">It tries to show the source as an actual page, and if I replace the "toHtml()" with "toPlainText()" all the html tags are removed... I'd like to show the source with all its tags in the textedit.</p>
<p dir="auto">Also, if I try to qDebug the source:</p>
<p dir="auto">qDebug() &lt;&lt; ui-&gt;webView-&gt;page()-&gt;currentFrame()-&gt;toHtml();</p>
<p dir="auto">nothing is shown...When I replace the tohtml with toplaintext it works (without the tags). Could this be because the source is to long for the qDebug to display? Thanks<br />
Richard</p>
]]></description><link>https://forum.qt.io/post/133731</link><guid isPermaLink="true">https://forum.qt.io/post/133731</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 27 Mar 2012 08:42:18 GMT</pubDate></item><item><title><![CDATA[Reply to [solved] Getting source from QWebView on Tue, 27 Mar 2012 08:22:39 GMT]]></title><description><![CDATA[<p dir="auto">@ui-&gt;webView()-&gt;page()-&gt;mainFrame()-&gt;toHtml();@<br />
or<br />
@ui-&gt;webView()-&gt;page()-&gt;currentFrame()-&gt;toHtml();@</p>
<p dir="auto">take a look at these classes : "QWebView":<a href="https://qt-project.org/doc/qt-4.8/qwebview.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-4.8/qwebview.html</a>, "QWebPage":<a href="https://qt-project.org/doc/qt-4.8/qwebpage.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-4.8/qwebpage.html</a>, "QWebFrame":<a href="https://qt-project.org/doc/qt-4.8/qwebframe.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-4.8/qwebframe.html</a> and "QWebElement":<a href="https://qt-project.org/doc/qt-4.8/qwebelement.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/doc/qt-4.8/qwebelement.html</a>.</p>
<p dir="auto">There are also a number of examples: "QtWebKit category":<a href="https://qt-project.org/wiki/Category:Developing_with_Qt::QtWebKit" target="_blank" rel="noopener noreferrer nofollow ugc">https://qt-project.org/wiki/Category:Developing_with_Qt::QtWebKit</a></p>
]]></description><link>https://forum.qt.io/post/133728</link><guid isPermaLink="true">https://forum.qt.io/post/133728</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 27 Mar 2012 08:22:39 GMT</pubDate></item></channel></rss>