Results 1 to 4 of 4

Thread: Copy files+ progress

  1. #1
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Copy files+ progress

    For copying files I use a following code :
    Qt Code:
    1. qint16 CWorkFiles::CopyFile(QString cSrc, QString cDst)
    2. {
    3. //QApplication::beep();
    4. if (!copy(cSrc,cDst))
    5. return -1;
    6. emit finished();
    7. return 1;
    8. }
    To copy to clipboard, switch view to plain text mode 
    how to receive percent of copying?

  2. #2
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy files+ progress

    I don't know of any Qt-way to do so - looks like you need to implement this functionality yourself and emit signal on what ever granularity you like.
    I see two possible implementation:

    1.) Open the source file, read the content in chunks to the app's memory and write the content to the target.
    This will work on all platforms, but is it will take much longer compared to a direct os-call.

    2.) Use os-specific functions to do so. On win32 you can use: CopyFileEx.
    You need to write code for all platforms you'd like to support.

    Good luck,

    Tom

  3. #3
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Copy files+ progress

    Quote Originally Posted by DeepDiver View Post
    I don't know of any Qt-way to do so - looks like you need to implement this functionality yourself and emit signal on what ever granularity you like.
    I see two possible implementation:

    1.) Open the source file, read the content in chunks to the app's memory and write the content to the target.
    This will work on all platforms, but is it will take much longer compared to a direct os-call.
    Yes, but i am have big files(5-30Gb)

    Quote Originally Posted by DeepDiver View Post
    2.) Use os-specific functions to do so. On win32 you can use: CopyFileEx.
    You need to write code for all platforms you'd like to support.
    is a not crossplatform

    Quote Originally Posted by DeepDiver View Post
    Good luck,
    Tom
    Thank for you answer

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: Copy files+ progress

    The most Qt-ish (but definitely not the fastest) way to do it is to use an object that will open source and destination file and perform a loop of reading a blob of data, writing it to the destination and emitting a signal reporting the progress. You can implement it around QIODevice::bytesWritten to make it asynchronous. A quicker but more dirty way would be to use fast platform dependent API like sendFile() on Linux (that doesn't copy data to userspace) in a thread and use QFileSystemWatcher to watch progress of the copy operation.

Similar Threads

  1. Mac: Copy Files Build Phase and qmake...
    By kuwan in forum Qt Programming
    Replies: 4
    Last Post: 25th September 2007, 20:59
  2. Replies: 5
    Last Post: 22nd September 2006, 08:04
  3. Copy progress bar
    By safknw in forum Newbie
    Replies: 13
    Last Post: 16th September 2006, 09:02
  4. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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.