void MainWindow::processing_list(QStringList &line)
{
//******
}
QStringList lst;
QtConcurrent::map(&lst,&this->processing_list);
no match for call to '(QtConcurrent::MemberFunctionWrapper1<void, MainWindow, QStringList&>) (QString&)'
map(*it);
...
QtConcurrent::map(lst, this->processing_list);
...
#include <QCoreApplication>
#include <QFuture>
#include <QtConcurrent/QtConcurrent>
#include <QString>
#include <QDebug>
void test(QString &str) {
qDebug() << str << " | ";
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QStringList strings;
strings << "test" << "test1";
QFuture<void> squeezedStrings = QtConcurrent::map(strings, &test);
return a.exec();
}
//mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QStringList>
#include <QFuture>
#include <QtConcurrent/QtConcurrent>
#include <QObject>
class MainWindow : public QObject
{
public:
MainWindow(QObject *parent = 0);
void start();
QStringList lst;
private:
static void processing_list(QString &line);
};
#endif // MAINWINDOW_H
//mainwindow.cpp
#include "mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QObject *parent) : QObject(parent){
}
void MainWindow::start() {
lst << "test" << "test1";
QtConcurrent::map(lst, &this->processing_list);
}
void MainWindow::processing_list(QString &line) {
qDebug() << line;
}
ParsingFile::ParsingFile(QList<QString> &list_string, int num_core, QObject *parent): QThread(parent)
{
this->row = &list_string;
this->number_core = num_core;
//qDebug() << "start core: " << number_core << endl;
}
void ParsingFile::run()
{
int maxThread = QThread::idealThreadCount();
for(int p=this->number_core; p < this->row->count(); p=p+maxThread)
{
QString tmp = row->at(p);
DATA_Channel T;
QString arg= "";
bool quote = false;
int num_arg = 0;
for(int i=0; i<tmp.length(); i++)
{
******
}
this->channel.push_back(T);
}
emit result_parse(this->channel);
}
int core = QThread::idealThreadCount();
for(int i=0; i<core; i++)
{
this->threads.push_back( new ParsingFile(row_lst,i) );
this->threads[i]->start(QThread::HighestPriority);
}