PDA

View Full Version : QTextBrowser and html



iamjayanth
6th July 2009, 12:13
Sir,

I am trying to use html in QTextBrowser..I have a Html file in my filesystem...
I am trying to print that on a QTextBrowser....But I cant...

This is the code that I used..


QTextBrowser * browser;
browser=new QTextBrowser(frame);
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning("file not found");
return;
}
while (!file.atEnd())
{
QByteArray line = file.readLine();
browser->setHtml(QString(line));
}


What am i missing....

Lykurg
6th July 2009, 14:51
Hi,

to use code in your post use "[" instead of "<". Second setHtml() does not append, it overwrite the whole html content, so better use:

if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning("file not found");
return;
}
browser->setHtml(file.readAll());

Third, we also have a Newbie section at this board. Just in case...

iamjayanth
6th July 2009, 15:49
Thank you lykurg...I am sorry if I put my thread in a wrong forum...Sorry about that..........