I wanted to run few functions using different threads or QProcess
or something which is more effective and also provide good performance. I am trying to build one gui for calibrator and as soon as I press calibrate button it needs to calibrate. For calibrating, I have some function to do that. However it takes some time to do this calibration process. Until my calibration is done my gui stays unresponsive. So what i am trying to do here is I would like to run that function in some parallel process or threads or some other things.
#include "widget.h"
#include "ui_widget.h"
#include <iostream>
#include <sstream>
#include <QtConcurrent/QtConcurrent>
#include <QFuture>
using namespace Eigen;
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->lineEdit->setReadOnly(true);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_pushButton_pressed()
{
ui->plainTextEdit->appendHtml("<div style='color: green;'> Calibrating ..... </div>");
QString body = ui->comboBox->currentText();
int body = body.toInt();
/*
I want to run calib function here in separate thread or QtConcurrent so my gui will stay resposive even my function takes some time close to 1 min to do calibration
*/
}
void Widget::printReceivedBody(int x)
{
}
void Widget::Calib(int x)
{
printReceivedBody(int x)
}
I checked some questions in stack and also in qt but unable to fix my problem.I found few questions but are trying to run executable. I can do via executable also but i would like to try above approach instead of going with executable.
I went to qt Documentaion but that documentation gives me more confusion :-(
Can someone suggest me how to do this?