emit make process more slowly ?
I want have indicator for my process. So i use a signal for update the progressbar value
Code:
//header MakanPakeSambal
signals:
updateProgress(qint64, qint64);
Code:
//code MakanPakeSambal
qDebug
() <<
"Start : " <<
QTime::currentTime().
toString("h:m:s");
qint64 ukuran=_inFileinfo.size();
qint64 i=0;
while(_inFile.getChar(&c))
{
outFile.putChar(c);
emit updateProgress(ukuran, i);
i++;
}
qDebug
() <<
"End : " <<
QTime::currentTime().
toString("h:m:s");
And I use like this
Code:
ui(new Ui::Dialog)
{
ui->setupUi(this);
mps=new MakanPakeSambal();
connect(mps, SIGNAL(updateProgress(qint64,qint64)), this, SLOT(load(qint64, qint64)));
}
void Dialog::load(qint64 max, qint64 curr)
{
ui->load->setMaximum(max);
ui->load->setValue(curr);
}
This is qDebug result without emit signal
Start : "18:3:28"
End : "18:3:42"
And with emit signal
Start : "18:4:20"
End : "18:12:15"
My method for get the progress value is wrong ?
Re: emit make process more slowly ?
You have a busy loop which blocks event processing. When you exit the loop you probably get a flood of updates of the ui->load object.
Re: emit make process more slowly ?
How big is input file ? Remember that every signal cause redrawing progress bar. Try this :
1. Create two signals. One for setting max value and one for stepping.
This first emit only one time.
2. Copy file with blocks not with single character.
Re: emit make process more slowly ?
Quote:
Originally Posted by
Lesiok
How big is input file ? Remember that every signal cause redrawing progress bar. Try this :
1. Create two signals. One for setting max value and one for stepping.
This first emit only one time.
2. Copy file with blocks not with single character.
1. Still slow
2. How to copy file with blocks ? Can you help me for show sample code ?