Results 1 to 5 of 5

Thread: Moving File/Folder in Qt

  1. #1
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Moving File/Folder in Qt

    Hi,

    I am trying to create a program which sorts the files in my download folder automatically as per categories, i want to be able to move files and folders with a progress bar. i am not sure how to approach the moving part of the program. i tried with QFile::copy and them remove recursively, which works but takes too long and gives me transfer error sometimes. is there any other approach, faster and reliable one.

    Thanks
    Arpit

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Moving File/Folder in Qt

    I don't know what OS your after, but if it's windows, then you have API function MoveFileWithProgress(), which can use a callback function so you can update a GUI. If it can't actually move the file (eg. it's in use, read only, or whatever) then it'll attempt to copy the file instead.

  3. #3
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Moving File/Folder in Qt

    Quote Originally Posted by fatjuicymole View Post
    I don't know what OS your after, but if it's windows, then you have API function MoveFileWithProgress(), which can use a callback function so you can update a GUI. If it can't actually move the file (eg. it's in use, read only, or whatever) then it'll attempt to copy the file instead.
    I use windows but i dont see a function called MoveFileWithProgress() in QT. there is one in windows MSDN API in WinBase.h, but i am not sure if i can use with MinGW for compiling.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Moving File/Folder in Qt

    Yes, sorry, I meant WinAPI function.

    Yes, you can use WinAPI functions such as that with MinGW (Qt, after all, uses WinAPI calls for a lot of it's own work)

  5. The following user says thank you to squidge for this useful post:

    arpspatel (17th January 2010)

  6. #5
    Join Date
    Apr 2008
    Posts
    35
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Moving File/Folder in Qt

    Thanks, Tried and worked on first try

Similar Threads

  1. Release folder - 1 .exe file only
    By Swankee in forum Qt Tools
    Replies: 6
    Last Post: 21st December 2009, 22:43
  2. Can't create folder if file with same name exists
    By Barry79 in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2009, 16:33
  3. qdirmodel question: show file number of a folder?
    By zl2k in forum Qt Programming
    Replies: 3
    Last Post: 7th November 2008, 07:07
  4. Replies: 2
    Last Post: 27th October 2007, 18:16
  5. Password on local file/folder
    By icebox25 in forum Qt Programming
    Replies: 3
    Last Post: 13th April 2007, 16:33

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.