Hi, I have a problem with the GUI for a laser beam propagation simulation I am currently writing with C++ and QT. The simulation itself works, but I implemented a dialog which should actually update a plot, using QCustomPlot and a progressBar. Unfortunately, the QDialog only appears after all the calculations are done, showing the plot of the final result and a progress bar at 100%.
Is there any way to make sure my dialog is actually visible during the calculations?
Here is how I create the dialog, after the preceding information has been processed:
void bpmSettings::runBPM()
{
//...
bpmdialog *b = new bpmdialog;
b->show();
this->close();
}
void bpmSettings::runBPM()
{
//...
bpmdialog *b = new bpmdialog;
b->show();
this->close();
}
To copy to clipboard, switch view to plain text mode
Here is the header of the dialog:
#ifndef BPMDIALOG_H
#define BPMDIALOG_H
#include <QDialog>
#include "vector2d.h" // a vector class I wrote which the simulation is based on
extern GaussData globalData;
namespace Ui {
class bpmdialog;
}
{
Q_OBJECT
public:
explicit bpmdialog
(QWidget *parent
= 0);
~bpmdialog();
private:
Ui::bpmdialog *ui;
void envPlot(const vector2d<double>& field); // plots the vector2d field by using the QCustomPlot widget in the ui.
void bpm(); // starts simulation
};
#endif // BPMDIALOG_H
#ifndef BPMDIALOG_H
#define BPMDIALOG_H
#include <QDialog>
#include "vector2d.h" // a vector class I wrote which the simulation is based on
extern GaussData globalData;
namespace Ui {
class bpmdialog;
}
class bpmdialog : public QDialog
{
Q_OBJECT
public:
explicit bpmdialog(QWidget *parent = 0);
~bpmdialog();
private:
Ui::bpmdialog *ui;
void envPlot(const vector2d<double>& field); // plots the vector2d field by using the QCustomPlot widget in the ui.
void bpm(); // starts simulation
};
#endif // BPMDIALOG_H
To copy to clipboard, switch view to plain text mode
And this is how my implementation of the dialog looks like:
bpmdialog
::bpmdialog(QWidget *parent
) : ui(new Ui::bpmdialog)
{
ui->setupUi(this);
bpm();
}
bpmdialog::bpmdialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::bpmdialog)
{
ui->setupUi(this);
bpm();
}
To copy to clipboard, switch view to plain text mode
I hope I provided enough information. The bpm() method is basically a for loop calculating a new 2d field in every iteration, by using a Gauss Seidel algorithm to solve a linear system. The 2d field is then plotted with the envPlot(field) method in every iteration.
Thank you very much in advance for your help!
Best regards,
Richard
Bookmarks