struct tipoRegistro {
qint16 val1;
qint16 val2 ;
qint16 val3;
};
tipoRegistro MainWindow::readFileStepByStep()
{
file.read(reinterpret_cast<char*> (®),sizeof(tipoRegistro));
return reg;
}
void MainWindow::qtConcurrentTest()
{
QVector<tipoRegistro> vector;
tipoRegistro treg;
treg.val1 = -1;
treg.val2 = -1;
treg.val3 = -1;
for(int i = 0; i < num_muestras_canal; i++)
vector.append(treg);
dialog.
setLabelText(QString("Cargando archivo ECG"));
QFutureWatcher<void> futureWatcher;
QObject::connect(&futureWatcher,
SIGNAL(finished
()),
&dialog,
SLOT(reset
()));
QObject::connect(&dialog,
SIGNAL(canceled
()),
&futureWatcher,
SLOT(cancel
()));
QObject::connect(&futureWatcher,
SIGNAL(progressRangeChanged
(int,
int)),
&dialog,
SLOT(setRange
(int,
int)));
QObject::connect(&futureWatcher,
SIGNAL(progressValueChanged
(int)),
&dialog,
SLOT(setValue
(int)));
futureWatcher.setFuture(QtConcurrent::mapped(vector,readFileStepByStep));
dialog.exec();
futureWatcher.waitForFinished();
}
struct tipoRegistro {
qint16 val1;
qint16 val2 ;
qint16 val3;
};
tipoRegistro MainWindow::readFileStepByStep()
{
file.read(reinterpret_cast<char*> (®),sizeof(tipoRegistro));
return reg;
}
void MainWindow::qtConcurrentTest()
{
QVector<tipoRegistro> vector;
tipoRegistro treg;
treg.val1 = -1;
treg.val2 = -1;
treg.val3 = -1;
for(int i = 0; i < num_muestras_canal; i++)
vector.append(treg);
QProgressDialog dialog;
dialog.setLabelText(QString("Cargando archivo ECG"));
QFutureWatcher<void> futureWatcher;
QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int)));
QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
futureWatcher.setFuture(QtConcurrent::mapped(vector,readFileStepByStep));
dialog.exec();
futureWatcher.waitForFinished();
}
To copy to clipboard, switch view to plain text mode
Bookmarks