Results 1 to 4 of 4

Thread: QUrl adds '/root' to the path

  1. #1
    Join Date
    May 2025
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QUrl adds '/root' to the path

    I need to get a file from device. The file is in /var/tmp directory, but when I try to get it, the error occurs.
    My code:
    Qt Code:
    1. QUrl url("ftp::/guest:guest@200.200.200.2:21/var/tmp/gps_info");
    2. QNetworkAccessManager* manager = new QNetworkAccessManager(this);
    3. connect(manager, SIGNAL(finished(QNetworkReplay*)), SLOT(slotFinished(QNetworkReplay*)));
    4.  
    5. QNetworkReplay replay = manager.get(QNetworkRequest(url));
    6. connect(replay , SIGNAL(errorOccured(QNetworkReplay::NetworkError)), SLOT(slotError(errorOccured(QNetworkReplay::NetworkError)));
    To copy to clipboard, switch view to plain text mode 

    Result: "Error while downloading ftp://guest:guest@200.200.200.2:21/r.../tmp/gps_info: /root/var/tmp/gps_info: No such file or directory".
    Why /root? What is mistake?

  2. #2
    Join Date
    May 2025
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QUrl adds '/root' to the path

    Eureka!
    Qt Code:
    1. QUrl url;
    2. url.setPath("//var/tmp/gps_info");
    3. url.setHost("200.200.200.2");
    4. url.setUserName("guest");
    5. url.setPassword("guest");
    6. url.setScheme("ftp");
    To copy to clipboard, switch view to plain text mode 
    It works! But...

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QUrl adds '/root' to the path

    In your original post you had "ftp:/guest..." instead of "ftp://guest...". Unless that was a typo, maybe that was the problem?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    May 2025
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QUrl adds '/root' to the path

    Of course "ftp://guest...". "ftp:/guest..." doesn't work.

Similar Threads

  1. QXmlQuery::evaluateTo(QString) adds a line break
    By mentalmushroom in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2018, 23:45
  2. Convert HTTP QUrl to file path on the server
    By atomic in forum Qt Programming
    Replies: 3
    Last Post: 5th November 2015, 11:23
  3. Change plarform folder path to root folder path
    By Alundra in forum Qt Programming
    Replies: 1
    Last Post: 24th February 2015, 22:53
  4. [ANN] ODB C++ ORM adds support for Qt
    By borisk in forum Qt Programming
    Replies: 0
    Last Post: 28th April 2011, 12:08
  5. PyQT QwtScaleDiv adds ticks to axis
    By mbernasocchi in forum Qwt
    Replies: 12
    Last Post: 13th April 2011, 11:29

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
  •  
Qt is a trademark of The Qt Company.