PDA

View Full Version : Performance problem with processEvents() on Mac OSX



ahmedb
10th May 2010, 15:01
Dear all,

- I have a SplashScreen form with a progressBar. and another class is doing processing in a large loop.

- the processing is emiting a signal that's connected to a slot in SplashScreen that updates progress-Bar value and calls processEvents()

- the problem is that when the processing loop was greater than 17,000,000 turns, progress takes over one hour in Mac OSX. however, the same loop took around 2 minutes in Windows and Linux.

Splashscreen.h



class SplashScreen : public QWidget
{
Q_OBJECT

public:
SplashScreen(QWidget *parent = 0);
~SplashScreen();

public slots:
void progress(qint32) ;
}


SplashScreen.cpp



void SplashScreen::progress(qint32 percent)
{
ui.progressBar->setValue(percent) ;
qApp->processEvents() ;
}


processing code:

Source code



connect(this, SIGNAL(progress(qint32)), splashScreenObj, SLOT(progress(qint32))) ;
...
for(int i=0;i<count;++i)
{
...
int percent = (int)((i/count) * 100.0f)
emit progress( percent) ;
}


How can I solve that ?

Thanks in advance,

Ahmed Bedier