Results 1 to 3 of 3

Thread: Open odt files with Qt

  1. #1
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Open odt files with Qt

    Hi
    I want open an odt file with my application.
    I have already opened pdf files- > this works without problems with the

    QDesktopServices:penUrl(QUrl("file:///path, QUrl::TolerantMode);

    but if I open an odt file with that command, it seems to open it, because the openoffice picture with the progressbar pops up, but the file stay closed....

    whats wrong?

    can u help me ? thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Open odt files with Qt

    For me it works (I tried only in Windows).

    Are your environment configured to launch OpenOffice Writer to read ODT files?

    Can you post the code?

    This in my code

    Qt Code:
    1. // Ask the user to select a ODT file
    2. void Widget::on_openUrlButton_clicked()
    3. {
    4. QString fileName = QFileDialog::getOpenFileName (
    5. this,
    6. tr ("Open File"),
    7. ".",
    8. tr ("Open Document Text Files (*.odt)"));
    9.  
    10. if (!fileName.isEmpty ()) {
    11. ui->urlEdit->setText (fileName);
    12. }
    13. }
    14.  
    15. // Launch proper application to read selected file
    16. void Widget::on_goButton_clicked()
    17. {
    18. QUrl url = QUrl::fromLocalFile (ui->urlEdit->text ());
    19.  
    20. bool result = QDesktopServices::openUrl (url);
    21. if (!result)
    22. qWarning () << "Failed to open URL " << url;
    23. }
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  3. The following user says thank you to mcosta for this useful post:

    Qiieha (29th April 2011)

  4. #3
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Open odt files with Qt

    Thank u for your reply. I'm on ubuntu, but your reply helped great. There where too much slashes in my code. It was my mistake . But if I create my QUrl like you, the problem had not ever occured.

Similar Threads

  1. qca, qca-gnupg Not able to open files
    By sky in forum Newbie
    Replies: 1
    Last Post: 15th February 2011, 06:11
  2. open files in different windows
    By ramaha8319 in forum Qt Tools
    Replies: 1
    Last Post: 27th April 2009, 14:27
  3. [Solved] Open files outside my program
    By Nykoo in forum Qt Programming
    Replies: 0
    Last Post: 27th January 2008, 16:13
  4. How to open IGES files in Qt Application?
    By Shuchi Agrawal in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 01:06
  5. integrating Qt files with open cascade??
    By Shuchi Agrawal in forum Qt Tools
    Replies: 1
    Last Post: 29th December 2006, 07:11

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.