How to open a text document( .doc or other) using Qt in linux



  • Hi,
    How can i open a document from the program , basically the document is kind of manual for our product.
    I actually want to create an Help kind of interface where the instructions are stored, but time being just openning a doc is enough.

    Regards,
    Dcqt


  • Moderators

    you may want to check out "Qt's help framework":http://qt-project.org/doc/qt-4.8/qthelp-framework.html.

    But as you said for the first time "this":http://qt-project.org/doc/qt-5.0/qtgui/qdesktopservices.html#openUrl would be enough for you:
    @
    QDesktopServices::openUrl( QUrl::fromLocalFile("<path-to-file>") );
    @


  • Moderators

    Run LibreOffice with QProcess. If you really want to parse and properly display doc files, you need to write your own parser.

    Much better idea is to use HTML help with QtWebKit, or compile QCH documentation. Doc as a filetype is deprecated, plus it's not an open standard like odf.



  • [quote author="raven-worx" date="1371728973"]you may want to check out "Qt's help framework":http://qt-project.org/doc/qt-4.8/qthelp-framework.html. But as you said for the first time "this":http://qt-project.org/doc/qt-5.0/qtgui/qdesktopservices.html#openUrl would be enough for you: @ QDesktopServices::openUrl( QUrl::fromLocalFile("<path-to-file>") ); @[/quote]
    Thanks a lot,
    Its working for files which have only text, but i have few screen shot images in my doc.

    I am getting following error.

    gvfs-open :file usermanual.doc :error opening location :operation not supported.

    is there any solution for this.


  • Moderators

    how does the returned value of QUrl::fromLocalFile() look like?
    A quick look up in the internet stated that "gvfs-open" has problems opening urls that have "% 2F" in it.



  • [quote author="sierdzio" date="1371729006"]Run LibreOffice with QProcess. If you really want to parse and properly display doc files, you need to write your own parser. Much better idea is to use HTML help with QtWebKit, or compile QCH documentation. Doc as a filetype is deprecated, plus it's not an open standard like odf.[/quote]

    Thanks very much..
    i QProcess with libreoffice... and it opened doc with images also.

    I will look into help stuff afterwards..



  • [quote author="raven-worx" date="1371734109"]how does the returned value of QUrl::fromLocalFile() look like? A quick look up in the internet stated that "gvfs-open" has problems opening urls that have "% 2F" in it.[/quote]

    no just

    gvfs-open :file usermanual.doc :error opening location :operation not supported

    there is no "% 2F" in it.



  • is there any way i can add reputation or some thing here


  • Moderators

    what i meant was the return value of QUrl::fromLocalFile() ... the value you pass to QDesktopServices::openUrl()


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.