我有一个名为RunProcess的函数。我想在并发进程中使用它来使GUI响应,所以我试图在并发进程中运行我的函数,但它不识别该函数。这是我的班级
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "gdal_priv.h"
#include "cpl_conv.h" // for CPLMalloc()
#include "ogr_srs_api.h"
#include <QDir>
#include <QFile>
#include <QDebug>
#include <iostream>
#include <cstring>
#include <string>
#include <QFileDialog>
#include <QThread>
#include <QtConcurrent/QtConcurrent>
using namespace QtConcurrent;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->startProcess, SIGNAL (released()), this, SLOT (StartProcess()));
}
void MainWindow::StartProcess(){
sendinfo("Starting Process... Note that the input images <b>must<\b> be in ESPG:3857.");
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"/home",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if(dir==""){
sendwarning("nothing is selected.");
return;
}
sendinfo("The selected folder is: "+dir);
QFuture<void> f1 = run(RunProcess,dir);
f1.waitForFinished();
}
void MainWindow::RunProcess( QString dir){
if(dir==""){
sendwarning("nothing is selected.");
return;
}
sendinfo("The selected folder is: "+dir);
QString path(dir);
QDir directory(path);
if(directory.exists()){
....
}else{
//directory does not exist
senderror("directory does not exist");
}
}
这是我的标题
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "gdal_priv.h"
#include "ogr_spatialref.h"
#include "gdal_utils_priv.h"
#include "cpl_error.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
void RunProcess();
~MainWindow();
public slots:
void StartProcess();
private:
Ui::MainWindow *ui;
void senderror(QString msg);
void sendinfo(QString msg);
void sendwarning(QString msg);
void gettext(QString msg,QString color);
};
#endif // MAINWINDOW_H
上面的代码返回
mainwindow.cpp:180: error: invalid use of non-static member function ‘void MainWindow::RunProcess()’
QFuture<void> f1 = run(RunProcess,dir);
^
你可以帮我找到我的错误吗?
感谢