Passing QString as parameter to a QFuture

185 views Asked by At

I need to pass a filename as QString with path to a function covered in a QFuture and watched by a QFutureWatcher, but only the first character of this QString will be passed to this function. Here the declaration in the *.h file:

qint64 processDataFile(const QString &fileName);
...
QFutureWatcher<qint64> *watcher;

And here the call of the function:

watcher = new QFutureWatcher<qint64>;
    connect(watcher, &QFutureWatcher<qint64>::finished, this, &SmartDCPD::fileProcessingFinished);
    qDebug() << log.fileName; // something like C:/users/.....
    watcher->setFuture(QtConcurrent::mapped(log.fileName, std::bind(&SmartDCPD::processDataFile, this, std::placeholders::_1)));

And the code of the function:

qint64 SmartDCPD::processDataFile(const QString &fileName)
{
qDebug() << fileName; //Only C (just the first char of the whole QString)
QElapsedTimer t;
t.start();
rapidcsv::Document doc(fileName.toUtf8().constData(), rapidcsv::LabelParams(-1, -1), rapidcsv::SeparatorParams(';'));
QString stamp = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss.zzz");
doc.SetCell<std::string>(1, 2, stamp.toUtf8().constData());
doc.Save();
return t.nsecsElapsed() / 1000000;
}

What am I doing wrong?

0

There are 0 answers