PDA

View Full Version : QDesktopServices::openUrl does not catch errors.



m1101101
17th May 2012, 14:37
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?

tferreira
17th May 2012, 14:52
If you want to validate a filepath, why don't you use QFile to check if the file exists?

m1101101
17th May 2012, 15:15
Thanks so much! I don't how I missed this!