Results 1 to 2 of 2

Thread: Get directory of QString

  1. #1
    Join Date
    Apr 2010
    Location
    Moscow
    Posts
    31
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Get directory of QString

    Hi there. I have a QString which contains a full path to a file. I need extract the directory out of it. And then I need create the directory with certain name specified by the second QString.

    Qt Code:
    1. QString full_path_name("c:\\folder1\\mynewJPG.jpg");
    To copy to clipboard, switch view to plain text mode 

    I want the final QString to be like this - "c:\\folder1\\myNewJPG.files\\". Thank you so much in advance.

  2. #2
    Join Date
    Apr 2010
    Location
    Moscow
    Posts
    31
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Get directory of QString

    Solved.

    Qt Code:
    1. QString current_jpg_name("c:\\myFolder\\jpg.jpg");
    2. QFileInfo fi(current_jpg_name);
    3. QString folder_name = fi.baseName();
    4. folder_name.append(".files"); // "jpg.files"
    5.  
    6. QDir tmp_dir(fi.dir());// "c:\\myFolder\\"
    7. tmp_dir.mkdir(folder_name); // "c:\\myFolder\\jpg.files\\"
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. With QString create a QString&
    By avis_phoenix in forum Newbie
    Replies: 1
    Last Post: 21st April 2010, 22:05
  2. Replies: 4
    Last Post: 1st February 2010, 14:21
  3. Replies: 4
    Last Post: 31st January 2008, 20:44
  4. Specify the DLL directory
    By Nyphel in forum Newbie
    Replies: 6
    Last Post: 27th April 2007, 14:29
  5. how to copy part of QString to anothe QString
    By nass in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2007, 19:05

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.