PDA

View Full Version : How to display a file in the textBrowser



deekayt
26th October 2006, 16:01
How to display a file in the textBrowser. The file name is available on the line edit selected through the filedialog via Windowsbrowser. I need to be able to display various text files as available in Windows that is .txt .doc .pdf etc


I have tried


QUrl url("file://c:/ver.txt" );
ui.textBrowser->clear();
ui.textBrowser->setHtml(ui.datalineEdit->text());
ui.textBrowser->show();
I tried other combinations but it did not work.This address of the url is perhaps the problem . In case of QT 3.3.4 on Unix it worked absolutely fine.

Any suggestions please.

patrik08
26th October 2006, 16:38
How to display a file in the textBrowser. The file name is available on the line edit selected through the filedialog via Windowsbrowser. I need to be able to display various text files as available in Windows that is .txt .doc .pdf etc
I have tried

QUrl url("file://c:/ver.txt" );
ui.textBrowser->clear();
ui.textBrowser->setHtml(ui.datalineEdit->text());
ui.textBrowser->show();
gestions please.

To display txt or html file inside qt have a look on source
http://ppk.ciz.ch/win_build/cms/html_editor.zip
Image insert , link , table edit & propriety , font , & other fanny ....

To display doc pdf inside qt i think is not possible! only Qprocess qt4.1 maybe qt3
http://www.qtcentre.org/forum/f-qt-programming-2/t-qdesktopservices-open-url-local-file-pdf-or-doc-4178.html

or the new QDesktopServices from qt4.2 can open the associate apps

jacek
26th October 2006, 19:47
I need to be able to display various text files as available in Windows that is .txt .doc .pdf etc
I wouldn't call .doc or .pdf file a text file. They're binary formats and QTextBrowser won't handle them. You could try to embed ActiveX controls in your application to display non-HTML files.


ui.textBrowser->setHtml(ui.datalineEdit->text());
What does ui.datalineEdit->text() contain? You are supposed to pass HTML code to QTextBrowser::setHtml(). Maybe you wanted to use QTextBrowser::setSource() instead?


To display doc pdf inside qt i think is not possible!
It is possible, but you have to use Active Qt or some 3rd party library.