PDA

View Full Version : Problem with screen update...



mysearch05
27th January 2006, 18:18
hi
i have written a module to send a file to the printer. The program works like:

//Pseodu
int i=0;
while(!eof(fptr){
ReadBuff(fptr,Buff,SIZE);
WriteToPrintf(Buff,SIZE);
ProgressBarUpdate(i);
i+=IncrementValue;
}

The file size is approx 4000bytes. The problem is while executing the above loop, the table which is displayed on the screen, the data disappears and screen seems to be frezzed. However, when the above operation is finished, the screen returns to normal.

Also, i want the progressbar to show the current status but the progressbar appears only after the entire contents are sent, showing directly 100%

i m using QT3.3.4

What can be the problem and possible remedies...

thanking in advance....

Timewarp
27th January 2006, 18:40
This sounds like you are doing all the "work" inside the eventloop of your dialog.
So the dialog is busy by looping and doing the work and can't update itself.
I would sugguest to move the code which is doing the work to a separate thread.

yop
27th January 2006, 19:24
//Pseodu
int i=0;
while(!eof(fptr){
ReadBuff(fptr,Buff,SIZE);
WriteToPrintf(Buff,SIZE);
ProgressBarUpdate(i);
qApp->processEvents(); // This will make your app responcive
i+=IncrementValue;
}

Kepp SIZE small.
But moving it to a new thread is the best solution.