Ha! Triumphed too early...
now it compiles fine, but since I instantiated MainWindow within void Dialog:
n_btnSend_clicked(), it seems that it dies after leaving the Function without writing to MainWindow's private variables.
Debugging the Function in Dialog returns exactly the values entered, debugging the MainWindow's variables show them empty. I must be totally blind, but I don't see what's going wrong here.
QString myTextString within Dialog: "Blabberdiblub"
QString myTextString within MainWindow: ""
int myIntegerzahl in Dialog: 11
int myIntegerzahl in Mainwindow: 2 (seems to be a value-by-chance).
I'm confused...
These are my Methods in mainwindow.cpp:
// Austausch-Methoden
void MainWindow
::setMyTextString(QString textstring
) {
myTextString = textstring;
qDebug() << myTextString;
}
QString MainWindow
::getMyTextString() {
return myTextString;
}
void MainWindow::setMyIntegerZahl(int integerzahl)
{
myIntegerZahl = integerzahl;
qDebug() << "myInt: " << myIntegerZahl << ", Int: " << integerzahl;
}
int MainWindow::getMyIntegerZahl()
{
return myIntegerZahl;
}
// Austausch-Methoden
void MainWindow::setMyTextString(QString textstring)
{
myTextString = textstring;
qDebug() << myTextString;
}
QString MainWindow::getMyTextString()
{
return myTextString;
}
void MainWindow::setMyIntegerZahl(int integerzahl)
{
myIntegerZahl = integerzahl;
qDebug() << "myInt: " << myIntegerZahl << ", Int: " << integerzahl;
}
int MainWindow::getMyIntegerZahl()
{
return myIntegerZahl;
}
To copy to clipboard, switch view to plain text mode
...and this is how I call them in my Dialog:
void Dialog::on_btnSend_clicked()
{
MainWindow myMainWindow; // Wichtig: MainWindow instanzieren, sonst Compilerfehler!!!
QString textstring
= this
->le_myTextString
->text
();
myMainWindow.setMyTextString(textstring);
myMainWindow.setMyIntegerZahl(this->spb_myIntegerZahl->value());
this->close();
}
void Dialog::on_btnSend_clicked()
{
MainWindow myMainWindow; // Wichtig: MainWindow instanzieren, sonst Compilerfehler!!!
QString textstring = this->le_myTextString->text();
myMainWindow.setMyTextString(textstring);
myMainWindow.setMyIntegerZahl(this->spb_myIntegerZahl->value());
this->close();
}
To copy to clipboard, switch view to plain text mode
...at last, this is my class definitions for MainWindow:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "dialog.h"
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
void setMyTextString
(QString textstring
);
int getMyIntegerZahl();
void setMyIntegerZahl(int integerzahl);
private slots:
void on_btnDialog_clicked();
void on_btnUebertrag_clicked();
private:
Ui::MainWindow *ui;
Dialog *myDialog;
QString myTextString;
// Ablage für Text aus dem Dialog int myIntegerZahl; // Ablage für Integer aus dem Dialog
};
#endif // MAINWINDOW_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "dialog.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
QString getMyTextString();
void setMyTextString(QString textstring);
int getMyIntegerZahl();
void setMyIntegerZahl(int integerzahl);
private slots:
void on_btnDialog_clicked();
void on_btnUebertrag_clicked();
private:
Ui::MainWindow *ui;
Dialog *myDialog;
QString myTextString; // Ablage für Text aus dem Dialog
int myIntegerZahl; // Ablage für Integer aus dem Dialog
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
aahh - sorry Lykurg, I didn't see you have already pointed to that failure. I'll give it a thought and try to rewrite that crap!
Bookmarks