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();
public slots:
void progress(qint32) ;
}
class SplashScreen : public QWidget
{
Q_OBJECT
public:
SplashScreen(QWidget *parent = 0);
~SplashScreen();
public slots:
void progress(qint32) ;
}
To copy to clipboard, switch view to plain text mode
SplashScreen.cpp
void SplashScreen::progress(qint32 percent)
{
ui.progressBar->setValue(percent) ;
qApp->processEvents() ;
}
void SplashScreen::progress(qint32 percent)
{
ui.progressBar->setValue(percent) ;
qApp->processEvents() ;
}
To copy to clipboard, switch view to plain text mode
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) ;
}
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) ;
}
To copy to clipboard, switch view to plain text mode
How can I solve that ?
Thanks in advance,
Ahmed Bedier
Bookmarks