Results 1 to 3 of 3

Thread: How to display a file in the textBrowser

  1. #1
    Join Date
    May 2006
    Posts
    68
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How to display a file in the textBrowser

    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

    Qt Code:
    1. QUrl url("file://c:/ver.txt" );
    2. ui.textBrowser->clear();
    3. ui.textBrowser->setHtml(ui.datalineEdit->text());
    4. ui.textBrowser->show();
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to display a file in the textBrowser

    Quote Originally Posted by deekayt View Post
    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
    Qt Code:
    1. QUrl url("file://c:/ver.txt" );
    2. ui.textBrowser->clear();
    3. ui.textBrowser->setHtml(ui.datalineEdit->text());
    4. ui.textBrowser->show();
    To copy to clipboard, switch view to plain text mode 
    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-p...-doc-4178.html

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

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to display a file in the textBrowser

    Quote Originally Posted by deekayt View Post
    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.

    Quote Originally Posted by deekayt View Post
    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?

    Quote Originally Posted by patrik08 View Post
    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.

  4. The following user says thank you to jacek for this useful post:

    deekayt (27th October 2006)

Similar Threads

  1. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  2. SQLite-DB in a qrc file
    By Lykurg in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2006, 19:24
  3. File permission QFile::WriteOther on Win Dos
    By patrik08 in forum Newbie
    Replies: 1
    Last Post: 13th June 2006, 14:16
  4. Accessing DTD in an XML file via QtXml module?
    By jorma in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2006, 18:09
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.