[Qt-interest] Progress Bar Logic

yogesh upreti yogesh.upreti at gmail.com
Fri May 28 11:54:15 CEST 2010


Hallo Andre,
Thanks for reply. I am using now reading and writing data with 16kb buffer
space.
This is working good for my programme, however it is taking more time than
the normal copy.

I have to use similier logic for reading txt files, but I am not getting
proper values. Here is what I do.

1. Calculate file size using QFile::size() function
2. Read file using QString line = QFile::readLine()  till  line.isEmpty()
 is not true
3. update the progress bar by line.size() value.

But this process is getting my progress bar only till 90-95% (depending on
file size).
Where do you think I am missing rest 5% of the file in this logic?

- Yogesh

Date: Fri, 28 May 2010 09:58:59 +0200
From: Andre Somers <andre at familiesomers.nl>
Subject: Re: [Qt-interest] Progress Bar Logic
To: qt-interest at trolltech.com
Message-ID: <4BFF77C3.8020705 at familiesomers.nl>
Content-Type: text/plain; charset="iso-8859-1"

On 27-5-2010 12:16, Ramesh wrote:
>
> Yogesh,
>
> I have not worked on Qt copy files. But as per my speculation, Qt has
> better API than what linux command which you use to Copy.
>
> Just googleit or look around the documentation , you may get solution.
>
> *From:* yogesh upreti [mailto:yogesh.upreti at gmail.com]
> *Sent:* Thursday, May 27, 2010 3:21 PM
> *To:* Ramesh
> *Cc:* qt-interest at trolltech.com
> *Subject:* Re: Progress Bar Logic
>
> Hallo Ramesh,
>
> Thanks for reply. I am using system command ("copy" for windows and cp
> for "unix") to copy files.
>
> How do I get the ammount of data copied? or is there a better way to
> copy file using any QT Function, so that I get also the ammount of
> data copied?
>
> Thanks
>
>

Qt provides QFile::copy, but that does not provide progress information.
Nor do the windows command copy or cp on *nix, AFAIK.
To do that, I think you'll have to implement the data copy yourself, by
reading chunks of data from your source file, and writing them away to
your destination file. You can then keep track of progress yourself, as
you know how big the source file is, and how many bytes you have read so
far.

Andr?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100528/0d24ca5a/attachment.html 


More information about the Qt-interest-old mailing list