我有一个在后台运行函数的应用程序,这是我的主要类
#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>
#include "databasemanager.h"
#include <sqlite_connection.h>
#include "locationinfo.cpp"
#include "gdal_wrap.h"
#include "gdalwarper.h"
#include "gdal_dem.h"
#include "shapefile_importer.h"
#include "gdal_contour.h"
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(std::bind1st(std::mem_fun(&MainWindow::RunProcess), this),dir);
f1.waitForFinished();
}
void MainWindow::RunProcess(QString dir){
......
}
MainWindow::~MainWindow()
{
delete ui;
}
正如你所看到的,我在QtConcurrent函数中运行我的函数,所以基于我的googles一定不能有任何空白的GUI但是当我运行应用程序时它会在linux中使GUI空白而如果我没有点击GUI上的某个地方它将关闭我的申请。
我在这里做错了什么?