[SOLVED] QUrl "file:" scheme trouble

  • @QUrl urlpath("file://");
    qDebug()<<urlpath.errorString();@ tell "Invalid URL".
    I'm trying to get some file from network via the QNetworkAccessManager. Can anybody show me mistake, please?
    Thnx for any help!

  • Moderators

    URLs contain the protocol used to access some resource on the network, not what you want to access.

    So "file://" does not state that you want to download a file but that you are accessing a resource in your local filesystem. file urls can not contain a host. Try "file:///somedir/somedoc.txt" instead (note the three slashes).

    Since file urls can never point to remote locations it makes little sense to involve the networkaccessmanager to get them.

  • Hmm... Strange. I thought it's ok. From WIKI:

    bq. To access a file "the file.txt", the following might be used.
    For a network location:
    file://hostname/path/to/the file.txtbq.

    Thank you anyway!

    P.S.: is there a simple way to get file from shared folder?

  • Moderators

    Mount the shared folder and then you can access files there like any other local file.

  • Thanks a lot! I'll try it.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.