[SOLVED]QDesktopServices::openUrl() fails to open a file with spaces
-
If i try opening a file:
@QString str="/home/ab/My Video.avi";
QDesktopServices::openUrl(str);
@It flags an error like : /home/ab/Mypercent20Video.avi does not exist. It seems QDesktopServices::openUrl() automatically encodes the url.
-
@
QString str="/home/ab/My Video.avi";
QDesktopServices::openUrl(QUrl::fromLocalFile(str));
@ -
If you pass QString instead of QUrl this will be automatically converted to:
@
QString str="/home/ab/My Video.avi";
QDesktopServices::openUrl(QUrl(str));
@and Qurl::QUrl(const QString &) constructor says:
bq. Constructs a URL by parsing url. url is assumed to be in human readable representation, with no percent encoding. QUrl will automatically percent encode all characters that are not allowed in a URL. The default parsing mode is TolerantMode.
Always use QUrl with right constructor or static function...
And please add "[SOLVED]" prefix left to the topic subject.
-
Thanks a lot for your reply!