Results 1 to 14 of 14

Thread: Copy progress bar

  1. #1
    Join Date
    May 2006
    Location
    Pune,India
    Posts
    63
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Copy progress bar

    Hi,
    I need a file copy progress bar.
    If (any body has)
    { pls send it to me; }
    else
    {
    how to copy file byte by byte in Qt ;
    how to keep file copy and progress bar in sync;
    }

  2. #2
    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 progress bar

    QUrlOperator, QProgressDialog.

    Copying byte by byte is very slow, it is better to use OS system calls to do that (at least through QFile::copy), but if you insist, something like this should work:

    Qt Code:
    1. QFile src("srcfile");
    2. QFile dst("dstfile");
    3. if(!src.open(QFile::ReadOnly) || !dst.open(QFile::WriteOnly)) return;
    4. qint64 len = src.bytesAvailable();
    5. dlg->setRange(0,len);
    6. dlg->show();
    7. char ch;
    8. while(!src.atEnd()){
    9. src.getChar(&ch);
    10. dst.putChar(ch);
    11. dlg->setValue(dlg->value()+1);
    12. qApp->processEvents();
    13. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2006
    Location
    Pune,India
    Posts
    63
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy progress bar

    Is there any other way to copy file manually in Qt3.

  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 progress bar

    What do you mean by "other" and "manually"? What's wrong with regular methods?

  5. #5
    Join Date
    May 2006
    Location
    Pune,India
    Posts
    63
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy progress bar

    Quote Originally Posted by wysota
    What do you mean by "other" and "manually"? What's wrong with regular methods?
    By "other" I mean other than above method (that u specify) to copy file. By manually I not using system calls.

  6. #6
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy progress bar

    What is wrong with QUrlOperator::copy() and connect to dataTransferred()
    We can't solve problems by using the same kind of thinking we used when we created them

  7. #7
    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 progress bar

    Quote Originally Posted by safknw
    By "other" I mean other than above method (that u specify) to copy file. By manually I not using system calls.
    The method with reading and writing byte by byte doesn't satisfy you too?

  8. #8
    Join Date
    May 2006
    Location
    Pune,India
    Posts
    63
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy progress bar

    It is quit slow, specially when u have to copy 80-100 Gb file.

  9. #9
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy progress bar

    When you want to copy a file about 80-100 GB in size, why do you want to copy Byte by Byte ? Why not in a block ?

    And what is wrong with the Qt's copy functions ?
    We can't solve problems by using the same kind of thinking we used when we created them

  10. #10
    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 progress bar

    Quote Originally Posted by safknw
    It is quit slow, specially when u have to copy 80-100 Gb file.
    That's why they invented system calls that copy files without the need to transfer every byte of the file to userspace. If you don't want to use them, you have to stick with copying every byte of the file yourself (it will be slow no matter if you copy byte by byte or kilobyte by kilobyte).

  11. #11
    Join Date
    May 2006
    Location
    Pune,India
    Posts
    63
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Copy progress bar

    Quote Originally Posted by sunil.thaha
    When you want to copy a file about 80-100 GB in size, why do you want to copy Byte by Byte ? Why not in a block ?

    And what is wrong with the Qt's copy functions ?
    Block by Block is OK but how.
    Qt'copy functions is not availble in Qt 3.3.x

  12. #12
    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 progress bar

    Quote Originally Posted by safknw
    Qt'copy functions is not availble in Qt 3.3.x
    Are you sure?
    QUrlOperator::copy()

  13. #13
    Join Date
    May 2006
    Location
    Pune,India
    Posts
    63
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: Copy progress bar

    My problem is that I have read the data from file, cypher/encrypt some part of it then save it to other file. I have to show the progress bar while doing this.

  14. #14
    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 progress bar

    So is the problem about copying the file or showing the progress bar? QProgressDialog has all you need if latter is the case.

Similar Threads

  1. copy file/s from QFileDialog
    By raphaelf in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 14:26
  2. Progress Bar to be shown!!!
    By Kapil in forum Qt Programming
    Replies: 7
    Last Post: 23rd May 2006, 09:36
  3. file copy in Qt 3.3.4 ?
    By npc in forum Newbie
    Replies: 6
    Last Post: 31st March 2006, 14:43
  4. how can i copy a directary using QDir
    By monaem in forum Qt Programming
    Replies: 5
    Last Post: 4th February 2006, 12:12

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.