PDA

View Full Version : emit make process more slowly ?



wirasto
31st December 2009, 10:18
I want have indicator for my process. So i use a signal for update the progressbar value



//header MakanPakeSambal
signals:
updateProgress(qint64, qint64);





//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


Dialog::Dialog(QWidget *parent) :
QDialog(parent),
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 ?

wysota
31st December 2009, 11:35
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.

Lesiok
31st December 2009, 12:34
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.

wirasto
31st December 2009, 16:51
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 ?