Hello, I am having a trouble getting a thread to continue restarting until a listWidget is finished with all of the items in it.
mainwindow.h
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
HeatTransferMain *hMain;
signals:
}
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
HeatTransferMain *hMain;
QThread T;
signals:
SimData(QString, QString, QString)
}
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
hMain = new HeatTransferMain;
}
void MainWindow::on_StartSimulation_Clicked()
{
RunMain();
}
void MainWindow::Progress()
{
if(ui->listWidget->count()>0)
delete ui->listWidget->takeItem(0);
RunMain();
}
void MainWindow::RunMain()
{
if(ui->listWidget->count()==0)
return;
QString sim_name_it
= ui
->listWidget
->item
(0)->text
();
emit(SimData(sim_name_it, Direc, Path));
hMain->DoSetup(T);
hMain->moveToThread(&T);
T.start();
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
hMain = new HeatTransferMain;
QThread * T = new QThread;
connect(this,SIGNAL(SimData(QString, QString, QString)),hMain,SLOT(SimulationData(QString, QString,QString))); // Connection of Main Data Structure
}
void MainWindow::on_StartSimulation_Clicked()
{
RunMain();
}
void MainWindow::Progress()
{
if(ui->listWidget->count()>0)
delete ui->listWidget->takeItem(0);
RunMain();
}
void MainWindow::RunMain()
{
if(ui->listWidget->count()==0)
return;
QString sim_name_it = ui->listWidget->item(0)->text();
emit(SimData(sim_name_it, Direc, Path));
hMain->DoSetup(T);
hMain->moveToThread(&T);
T.start();
}
To copy to clipboard, switch view to plain text mode
When the Thread is done for the first Sim_name_it, the progress function is emitted by the thread. The Progress function calls RunMain(), but the thread never starts. Any ideas will be helpful!
note: the code was edited for readability, if something is not defined it was probably removed because it was deemed not important.
Bookmarks