I've based this section of my code on the terminal example. When I update a field in my mainwindow I wasn't to store the generated string in a structure, then when a command is called in my secondary source, I want to use the passed string.
In my main.h I have
struct Settings {
QString Id;
};Settings settings() const;
private:
Ui::MainWindow *ui;
Settings currentSettings;
In my main.cpp is the code that set the value of Id
void MainWindow::on_comboBox_currentTextChanged(const QString &arg1)
{
QString Data = arg1;
if (arg1 == "Universal"){
Data = "xxx";
}
else{
Data = Format_Class::format_3(Data);
}
currentSettings.Id = Data;
}
MainWindow::Settings MainWindow::settings() const
{
return currentSettings;
}
this code defiantly works because currentsettings id gets set to the correct value.
in my mode.H I have
namespace Ui {
class Mode;
}
class MainWindow;
class Mode : public QDialog
{
Q_OBJECT
public:
explicit Mode(QWidget *parent = 0);
~Mode();
private:
Ui::Mode *ui;
MainWindow *settings;
};
then in my mode.cpp, the page that actually uses the data I have
void Mode::on_pushButton_clicked()//ok
{
MainWindow::Settings p = settings -> settings();
QString hash = "#";
QString end = "\r";
QString identifier = (p.Id);
the function get to the
MainWindow::Settings p = settings -> settings();
at which it develops a fatal error and crashes. In debugging mode when return currentsettings gets called, currentSettings / id is <not accessible>
this is after this the program crashes.
when the program crashes the error that occurs is
Signal received
The inferior stopped because it received a signal from the operating system
Signal name: SIGSEGV Signal meaning: Segmentation fault