Debug says vaiable is empty but it isn't
Hallo,
my program is split into several cpp and h files.
The GUI window is in dialog.cpp and dialog.h
The scan is in scan.cpp and scan. h
Save is in file.cpp and file.h
Scan is storing the results in a public QVector. When i hit a button in GUI i can see the output of QVector in the debug. When I hit save, nothing from the QVector is saved. Debugger shows QVector empty.
dialog.h
Code:
private:
Ui::Dialog *ui;
FM_rds mRds;
Scan mScan;
Tune mTune;
Mute mMute;
File mFile;
dialog.cpp (show content of QVector in Debug and save button)
Code:
void Dialog::on_pushButton_clicked()
{
qDebug() << "dab_vev_vec: " << mScan.dab_vec_vec;
}
void Dialog::on_pushButton_2_clicked()
{
mFile.dab_write_file();
}
file.h
Code:
#include <scan.h>
private:
Scan mScan;
file.cpp
Code:
for(int i = 0; i < mScan.dab_vec_vec.size(); i++){
dab_vec_vec_to_line = mScan.dab_vec_vec[i][0] + "," + mScan.dab_vec_vec[i][1] + "," + mScan.dab_vec_vec[i][2] + "," + mScan.dab_vec_vec[i][3];
qDebug() << "i: " << i << "dabvecvectoline: " << dab_vec_vec_to_line;
unsort_list.append(dab_vec_vec_to_line);
}
scan.h
Code:
public:
QVector<QVector<QString>> dab_vec_vec;
Re: Debug says vaiable is empty but it isn't
mScan in dialog,h and file.h is not the same object.
Re: Debug says vaiable is empty but it isn't
Ok, how can I access the variable for File else? I wanted to avoid using a global variable.
Re: Debug says vaiable is empty but it isn't
Keep mScan in one class (your File class, for example). Add a setScans() method to your Dialog class to copy this data into the Dialog class instance before your call to exec(). Or keep it in your Dialog class and pass it as an argument to File:: dab_write_file().