PDA

View Full Version : QTextBrowser: Cannot open



veda
27th December 2007, 11:43
I want to open a html file in the text browser ,
and the code is as follows:



#include <QtGui>
#include <QUrl>
#include <QTextBrowser>
int main(int argc, char **argv)
{
QApplication app( argc, argv );
QTextBrowser *bw = new QTextBrowser;
bw->setSource (QUrl("D:\\Wikipedia.html"));
bw->setGeometry ( 100,100,400,400 );
bw->show();
return app.exec();
}




QFSFileEngine::open: No file name specified
QTextBrowser: Cannot open 'D:\Wikipedia.html' for reading
QTextBrowser: No document for D:\Wikipedia.html


But the browser is unable to open the file ...

What changes has to be made to identify the file and open it????

wysota
27th December 2007, 11:47
Try QUrl::fromLocalFile

veda
27th December 2007, 11:56
I am not getting warning after using QUrl::fromLocalFile


Try QUrl::fromLocalFile

but the html file is still not displayed on to my TextBrowser.

It shows blank widget of TextBrowser.

Do I need to set some other properties.

wysota
27th December 2007, 12:05
Maybe the file doesn't contain proper contents? Try some other file for example with the following content:
<html><body>TEST</body></html>