Please nominate your Qt Champions for 2021!

[SOLVED]QDesktopServices::openUrl() fails to open a file with spaces

  • If i try opening a file:
    @QString str="/home/ab/My Video.avi";

    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";

  • If you pass QString instead of QUrl this will be automatically converted to:
    QString str="/home/ab/My Video.avi";

    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!

Log in to reply