Hi there! This is my first post to qt central. I'm stuck with my trials to save the contents of a Dialog in the calling MainWindow (MainWindow and Dialog created in QTcreator). The scenario: I have a MainWindow with a line edit, an integer spinbox and two buttons (one calls up the Dialog, the other one should call a public function that reads some private variables of class MainWindow and puts them into the line edit and the integer spinbox) and a Dialog with the same input Gadgets.
Plan was to write some public methods in class MainWindow that should have been used by class Dialog in order to store the values of the Dialog's input wigets in class MainWindow's private vars myTextString and myIntegerZahl.

Showing up the Dialog works, unless I call void setMyTextString(QString textstring); - in that case the program refuses to compile, throwing an error: "cannot call member function 'void MainWindow::setMyTextString(QString)' without object".

I did some reading on the Qt examples, but failed to find one that shows what I'm aiming at. Could somebody please show me the correct way of transfering the contents of my Dialog? Here comes the code:

mainwindow.h
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include "dialog.h"
  6.  
  7. namespace Ui {
  8. class MainWindow;
  9. }
  10.  
  11. class MainWindow : public QMainWindow
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. explicit MainWindow(QWidget *parent = 0);
  17. ~MainWindow();
  18. void getMyTextString();
  19. void setMyTextString(QString textstring);
  20. void getMyIntegerZahl();
  21. void setMyIntegerZahl();
  22.  
  23. private slots:
  24. void on_btnDialog_clicked();
  25. void on_btnUebertrag_clicked();
  26.  
  27. private:
  28. Ui::MainWindow *ui;
  29. Dialog *myDialog;
  30. QString myTextString;
  31. int myIntegerZahl;
  32. };
  33.  
  34. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. //#include "dialog.h"
  5.  
  6. MainWindow::MainWindow(QWidget *parent) :
  7. QMainWindow(parent),
  8. ui(new Ui::MainWindow)
  9. {
  10. ui->setupUi(this);
  11. }
  12.  
  13. MainWindow::~MainWindow()
  14. {
  15. delete ui;
  16. }
  17.  
  18. void MainWindow::on_btnDialog_clicked()
  19. {
  20. myDialog = new Dialog;
  21. myDialog->exec();
  22. ui->le_myTextString->setEnabled(true);
  23. }
  24.  
  25. void MainWindow::on_btnUebertrag_clicked()
  26. {
  27.  
  28. }
  29.  
  30. // Austausch-Methoden
  31. void MainWindow::setMyTextString(QString textstring)
  32. {
  33. myTextString = textstring;
  34. }
To copy to clipboard, switch view to plain text mode 


dialog.h
Qt Code:
  1. #ifndef DIALOG_H
  2. #define DIALOG_H
  3.  
  4. #include "ui_dialog.h"
  5.  
  6. //#include <QDialog>
  7.  
  8. namespace Ui {
  9. class Dialog;
  10. }
  11.  
  12. class Dialog : public QDialog, public Ui::Dialog
  13. {
  14. Q_OBJECT
  15.  
  16. public:
  17. Dialog();
  18.  
  19. private slots:
  20. void on_btnSend_clicked();
  21.  
  22. private:
  23. Ui::Dialog *ui;
  24. };
  25.  
  26. #endif // DIALOG_H
To copy to clipboard, switch view to plain text mode 

dialog.cpp
Qt Code:
  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3. #include "mainwindow.h"
  4.  
  5. Dialog::Dialog()
  6. {
  7. setupUi(this);
  8. }
  9.  
  10. void Dialog::on_btnSend_clicked()
  11. {
  12. QString textstring = this->le_myTextString->text();
  13. MainWindow::setMyTextString(textstring);
  14. }
To copy to clipboard, switch view to plain text mode 

Any hints appreciated!