I need to increment progressbar in qt everytime a file is copied from one location to another. Example there are 64 files to be copied. How is it possible to let the progressbar know the amount to increment by. Following is help code. Could you exhaust on it.
class MyClass : ...
{
...
public slots:
void onWrite( qint64 );
};
MyClass::MyClass( ... )
{
// ...
progress->setMaximum( QFileInfo(fromFile).size() / 1024 );
written = 0;
connect( &toFile, SIGNAL(bytesWritten(qint64)), SLOT(onWrite(qint64)) );
// ...
}
void MyClass::onWrite( qint64 w )
{
written += w;
progress->setValue( written / 1024 );
}