PDA

View Full Version : QProgressDialog and QTcpSocket



tom989
29th March 2013, 01:24
I'd like to have a progress dialog for writing to a TCP socket but I'm unsure as to which QTcpSocket signal to connect to QProgressDialog::setvalue().



Can anyone help?

Thanks!

wysota
29th March 2013, 01:53
There is no such signal. You need to keep track of how much you have written to the socket yourself.

ChrisW67
29th March 2013, 02:04
There's no meaningful measure to be had from a signal AFAICT: no signal carries a cumulative total. When your code writes, update the progress bar however you want.

Edit: Pipped by wysota.

tom989
29th March 2013, 02:27
So I would have to do something like dividing my file into appropriately sized chunks,writing each chunk (then wait for waitForBytesWritten signal) and update the progress bar?

wysota
29th March 2013, 07:26
So I would have to do something like dividing my file into appropriately sized chunks,writing each chunk (then wait for waitForBytesWritten signal) and update the progress bar?

How and what you write to the socket is meaningless to the problem. You can use QIODevice::bytesWritten() signal to measure how much was really written to the device but keeping track of how much is left (aka what's the total number of bytes) is what you need to do manually.