<?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[Need help to display the preview of the content of file in text browser]]></title><description><![CDATA[<p dir="auto">This is my code snippet:</p>
<p dir="auto">@<br />
void MainWindow::on_filteredTreeView_clicked(const QModelIndex &amp;index)<br />
{<br />
QString strIndex = index.data(QFileSystemModel::FilePathRole).toString();<br />
QFile file(strIndex);<br />
QFileInfo fileInfo(strIndex);</p>
<pre><code>if (fileInfo.suffix() == "txt")
{
    file.open(QIODevice::ReadOnly);
    QTextStream in(&amp;file);
    ui-&gt;textBrowser-&gt;setText(in.readAll());
    file.close();
}
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">I just managed to extract the content of .txt file only to be display in the text browser.<br />
How do I want to extract the content of other file extension such as .jpg, .docx and others?</p>
]]></description><link>https://forum.qt.io/topic/49009/need-help-to-display-the-preview-of-the-content-of-file-in-text-browser</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 08:57:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/49009.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Dec 2014 08:16:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Wed, 10 Dec 2014 05:39:00 GMT]]></title><description><![CDATA[<p dir="auto">How do I want to open the preview of the content of the .pdf, .docx, .xls and others file type in the QTextBrowser?<br />
Any idea?</p>
]]></description><link>https://forum.qt.io/post/253759</link><guid isPermaLink="true">https://forum.qt.io/post/253759</guid><dc:creator><![CDATA[slumberdin]]></dc:creator><pubDate>Wed, 10 Dec 2014 05:39:00 GMT</pubDate></item><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Wed, 10 Dec 2014 02:32:00 GMT]]></title><description><![CDATA[<p dir="auto">I managed to display .jpg in my QTextBrowser.<br />
But in the application output, it says:<br />
"QFSFileEngine::open: No file name specified"</p>
<p dir="auto">Can someone explain the this error?</p>
<p dir="auto">This is my code snippet:<br />
@<br />
else if (fileInfo.suffix() == "jpg" || fileInfo.suffix() == "gif" || fileInfo.suffix() == "png" || fileInfo.suffix() == "tiff" || fileInfo.suffix() == "tiff")<br />
{<br />
QString strPre = QString("&lt;img  /&gt; ");<br />
ui-&gt;textBrowser-&gt;setHtml(strPre);<br />
}<br />
@</p>
<p dir="auto">Edited: Suppose in the line 3, I wrote like this,<br />
src="" + fileInfo.filePath() + "" after "img" and before "/&gt;".</p>
<p dir="auto">I don't know why it don't want to appear.</p>
]]></description><link>https://forum.qt.io/post/253750</link><guid isPermaLink="true">https://forum.qt.io/post/253750</guid><dc:creator><![CDATA[slumberdin]]></dc:creator><pubDate>Wed, 10 Dec 2014 02:32:00 GMT</pubDate></item><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Tue, 09 Dec 2014 14:03:52 GMT]]></title><description><![CDATA[<p dir="auto">Yes, text browser can display image.<br />
See example "here":<a href="http://qt-project.org/doc/qt-5/qtextedit.html#drag-and-drop" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5/qtextedit.html#drag-and-drop</a></p>
]]></description><link>https://forum.qt.io/post/253696</link><guid isPermaLink="true">https://forum.qt.io/post/253696</guid><dc:creator><![CDATA[andreyc]]></dc:creator><pubDate>Tue, 09 Dec 2014 14:03:52 GMT</pubDate></item><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Tue, 09 Dec 2014 14:02:49 GMT]]></title><description><![CDATA[<p dir="auto">QTextBrowser (if we are talking about this widget) can handle HTML, so it should be possible to put in a standard &lt;img&gt; tag there.</p>
<p dir="auto">But it is much easier to display an image on a QLabel.</p>
]]></description><link>https://forum.qt.io/post/253695</link><guid isPermaLink="true">https://forum.qt.io/post/253695</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Tue, 09 Dec 2014 14:02:49 GMT</pubDate></item><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Tue, 09 Dec 2014 13:52:55 GMT]]></title><description><![CDATA[<p dir="auto">I want to display the image on the text browser.<br />
That means I want to see the image on the text browser.<br />
I don't want to do any change to the property of date modified of the file.<br />
That's why I using read only when I want to read .txt file.<br />
Does the text browser can display the image of .jpg?<br />
Or the text browser can display a bundle of text only?</p>
]]></description><link>https://forum.qt.io/post/253694</link><guid isPermaLink="true">https://forum.qt.io/post/253694</guid><dc:creator><![CDATA[slumberdin]]></dc:creator><pubDate>Tue, 09 Dec 2014 13:52:55 GMT</pubDate></item><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Tue, 09 Dec 2014 08:58:42 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="slumberdin" date="1418114990"]How do I can output it to the textbrowser?[/quote]</p>
<p dir="auto">That depends on what you want to see in there. Binary data? EXIF information? Some basic picture properties (size, color depth)?</p>
<p dir="auto">All those are possible, but need to be implemented in a different way.</p>
]]></description><link>https://forum.qt.io/post/253653</link><guid isPermaLink="true">https://forum.qt.io/post/253653</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Tue, 09 Dec 2014 08:58:42 GMT</pubDate></item><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Tue, 09 Dec 2014 08:49:50 GMT]]></title><description><![CDATA[<p dir="auto">Thanks to your help.<br />
But, can I ask something?<br />
How do I can output it to the textbrowser?</p>
]]></description><link>https://forum.qt.io/post/253650</link><guid isPermaLink="true">https://forum.qt.io/post/253650</guid><dc:creator><![CDATA[slumberdin]]></dc:creator><pubDate>Tue, 09 Dec 2014 08:49:50 GMT</pubDate></item><item><title><![CDATA[Reply to Need help to display the preview of the content of file in text browser on Tue, 09 Dec 2014 08:41:04 GMT]]></title><description><![CDATA[<p dir="auto">@<br />
else if (fileInfo.suffix() == "jpg")<br />
{<br />
QImage my Img(fileInfo.path());<br />
// do something with the image<br />
}<br />
@</p>
]]></description><link>https://forum.qt.io/post/253649</link><guid isPermaLink="true">https://forum.qt.io/post/253649</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Tue, 09 Dec 2014 08:41:04 GMT</pubDate></item></channel></rss>