Results 1 to 3 of 3

Thread: QDesktopServices::openUrl does not catch errors.

  1. #1
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QDesktopServices::openUrl does not catch errors.

    I've seen a post with a similar problem, but I have yet to find a solution.

    I am trying to open various files in their default applications from QT, and I am using QDesktopServices::openUrl(QUrl). When a file cannot be found, it outputs the following error to the command line:

    Error showing url: Error stating file '[filepath]': No such file or directory

    There seems to be no way to catch this error and pop up a notification to the user; openUrl returns true every time, regardless of the result. I hoped that validating the QUrl might turn up an error before I even call openUrl, but the QUrl returns the same errorString() and isValid() result for both files that open and files that fail.

    Any suggestions for catching the openUrl error or creating a workaround?
    Last edited by m1101101; 17th May 2012 at 15:16.

  2. #2
    Join Date
    Sep 2011
    Location
    Portugal
    Posts
    25
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QDesktopServices::openUrl does not catch errors.

    If you want to validate a filepath, why don't you use QFile to check if the file exists?

  3. #3
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Wink Re: QDesktopServices::openUrl does not catch errors.

    Thanks so much! I don't how I missed this!

Similar Threads

  1. QDesktopServices::openUrl() slow
    By rbp in forum Qt Programming
    Replies: 10
    Last Post: 23rd January 2011, 16:30
  2. local html file and QDesktopServices::openUrl
    By ntp in forum Qt Programming
    Replies: 1
    Last Post: 19th August 2010, 08:05
  3. Replies: 1
    Last Post: 3rd February 2010, 04:45
  4. QDesktopServices::openUrl - Problem
    By rmagro in forum Qt Programming
    Replies: 8
    Last Post: 2nd April 2009, 14:21
  5. QDesktopServices::openUrl and HTML fragments
    By roro in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2007, 17:31

Tags for this Thread

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.