Results 1 to 3 of 3

Thread: QUrl parsing?

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QUrl parsing?

    I see how with QUrl, you can get the host, query string, fragment, path, authority from a given URL. Is there an easy way to get the filename from the URL? For instance, for http://doc.trolltech.com/4.3/qurl.html#path, I want just the "qurl.html" ...?
    Software Engineer



  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QUrl parsing?

    I am not sure, but you can try this:
    Qt Code:
    1. QFileInfo fileInf(url.toLocalFile()); //maybe url.toString() might also be good
    2. QString fileName = fileInf.fileName();
    To copy to clipboard, switch view to plain text mode 

    Or something along these lines...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QUrl parsing?

    Or retrieve the path(), split it on slashes and take the last component.

  4. The following user says thank you to wysota for this useful post:

    gfunk (17th January 2008)

Similar Threads

  1. Parsing Files
    By JayJay in forum Qt Programming
    Replies: 13
    Last Post: 20th August 2007, 19:01
  2. parsing using QDOM
    By aruna in forum Qt Programming
    Replies: 1
    Last Post: 17th July 2007, 12:46
  3. XML Parsing in Qt 3.3
    By ToddAtWSU in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2007, 18:54
  4. Config file parsing
    By Vash5556 in forum Qt Programming
    Replies: 2
    Last Post: 10th September 2006, 23:11
  5. HTML Parsing
    By awalesminfo in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2006, 11:31

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.