Hi everyone!
I'm a new member of forum and I'm a beginner with Qt. I searched in forum if somebody else had the same problem, but I found the solution only for the reverse problem.
My problem is the following:
I have a QMainWindow (Qsem2D) with some member data and with a button which when is clicked open a QDialog (SettingSolver) window that is a child of QMainWindow.
Qsem2D:
Qsem2D.h
#include <QMainWindow>
{
.....
private:
bool *m_isForward;
signals:
void signalIsForward(bool i_isForward);
private slots:
void on_pushButton_clicked();
void sendSignalToSettingSolver();
.....
}
#include <QMainWindow>
class Qsem2d : public QMainWindow
{
.....
private:
bool *m_isForward;
signals:
void signalIsForward(bool i_isForward);
private slots:
void on_pushButton_clicked();
void sendSignalToSettingSolver();
.....
}
To copy to clipboard, switch view to plain text mode
Qsem2D.cpp
#include Qsem2D.h
#include SolverSetting.h
....
void Qsem2D::on_pushButton_clicked()
{
sendSignalToSettingSolver();
SolverSetting *newWindow = new SolverSetting;
newWindow->show;
}
void Qsem2D::sendSignalToSettingSolver()
{
emit signalIsForward(*m_isForward);
}
#include Qsem2D.h
#include SolverSetting.h
....
void Qsem2D::on_pushButton_clicked()
{
sendSignalToSettingSolver();
SolverSetting *newWindow = new SolverSetting;
newWindow->show;
}
void Qsem2D::sendSignalToSettingSolver()
{
emit signalIsForward(*m_isForward);
}
To copy to clipboard, switch view to plain text mode
SettingSolver:
SettingSolver.h
#include "Qsem2D.h"
#include <QDialog>
class SettingSolver
: public QDialog{
public:
SettingSolver(Qsem2D *parent = 0);
~SettingSolver();
.....
private:
bool *m_isForward;
private slots:
void receiveSignalFromMainWindow(bool i_isForward);
}
#include "Qsem2D.h"
#include <QDialog>
class SettingSolver : public QDialog
{
public:
SettingSolver(Qsem2D *parent = 0);
~SettingSolver();
.....
private:
bool *m_isForward;
private slots:
void receiveSignalFromMainWindow(bool i_isForward);
}
To copy to clipboard, switch view to plain text mode
SettingSolver.cpp
#include "SettingSolver.h"
#include <QDialog>
SettingSolver::SettingSolver(Qsem2D *parent):
ui(new Ui::SettingSolver),
m_isForward(new bool)
{
.....
connect(parent,SIGNAL(signalIsForward),this,SLOT(receiveSignalFromMainWindow)
if(*m_isForward)
{
....
}
.....
}
void SolverSetting::receiveSignalFromMainWindow(bool i_isForward)
{
*m_isForward = i_isForward;
}
#include "SettingSolver.h"
#include <QDialog>
SettingSolver::SettingSolver(Qsem2D *parent):
QDialog(parent),
ui(new Ui::SettingSolver),
m_isForward(new bool)
{
.....
connect(parent,SIGNAL(signalIsForward),this,SLOT(receiveSignalFromMainWindow)
if(*m_isForward)
{
....
}
.....
}
void SolverSetting::receiveSignalFromMainWindow(bool i_isForward)
{
*m_isForward = i_isForward;
}
To copy to clipboard, switch view to plain text mode
The code could contain some errors because I don't have the original code handy but what I want understand is the concept.
My need is to pass the member data Qsem2D::m_isForward from MainWindow to member data SolverSetting::m_isForward (QDialog). For how the code is made now when I call the constructor for SolverSetting the member data SolverSetting::m_isForward is a pointer that points to memory allocation with no sense information instead I wish that it contains the value of Qsem2D::m_isForward.
What's wrong?
Thanks.
Regards.
Bookmarks