Qt-interest Archive, March 2002
Need for speed vs. QApplication::processEvents()
Message 1 in thread
Hi,
in my app I have a couple of imagefilters (blur,rotate and the like).
Since those operations may take a while, I'm using the following approach:
<pseudo code>
bool SomeFilter::applyFilter(QImage* image)
{
int progress;//range 0 - 100
while(processing_image)
{
//do lots of stuff here
if(user_stopped_the_show)
return false;
if((progress % 10) == 0)
{
emit signalProgress(progress);
qApp->processEvents();
}
}
return true;
}
signalProgress(int) is connected to a slot in a QMainWidget derived class,
which updates a QProgressWidget. There's also a stop button to abort the
operation. This works rather well, however, the performance drops enormously
just because of this qApp->processEvents() call. If I let applyFilter()
block, it's more than three times faster. Does someone know a faster
(non-blocking) method or has some ideas how to speed this up?
I'm using Qt2.3.1 (no thread support).
Thanks
Michael