Variabel Zugriff von anderer Klasse (QT)
-
Hallo Commnuity,
Ich weis das es eine einfache Frage ist aber ich komme einfach nicht weiter. Ich habe ein Main Widget von dem aus ein Dialog geöffnet wird. Die Werte des Dialog möchte ich gern im Main Widget zur verfügung haben aber es klappt einfach nicht. Ich bekomme kein Fehler ausgegeben der Rückgabe Wert ist einfach Leer.
Dialog Header:
#ifndef EINGABEDIALOG_H #define EINGABEDIALOG_H #include <QtGui> namespace Ui { class EingabeDialog; } class EingabeDialog : public QDialog { Q_OBJECT public: EingabeDialog(QWidget *parent = 0); ~EingabeDialog(); QLineEdit *Nr_von_LineEdit, *Nr_bis_LineEdit, *Fehler_1_LineEdit, *Fehler_2_LineEdit; QString getNr_von(); protected: void changeEvent(QEvent *e); public slots: void einlesen(); private: QString nr_von; Ui::EingabeDialog *m_ui; QDialogButtonBox *ButtonBox; }; #endif // EINGABEDIALOG_HDialog CPP
#include "eingabedialog.h" #include "ui_eingabedialog.h" EingabeDialog::EingabeDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::EingabeDialog){ m_ui->setupUi(this); Nr_von_LineEdit = new QLineEdit; Nr_von_LineEdit = m_ui->Baunummer_von; Nr_von_LineEdit->setInputMask("999"); ButtonBox = new QDialogButtonBox; ButtonBox = m_ui->buttonBox; connect(ButtonBox, SIGNAL(accepted()), this, SLOT(einlesen())); } EingabeDialog::~EingabeDialog() { delete m_ui; } QString EingabeDialog::getNr_von(){ return nr_von; } void EingabeDialog::einlesen(){ nr_von = Nr_von_LineEdit->text(); }Main Widget
EingabeDialog *in_Dialog = new EingabeDialog(this); QString ausgabe = in_Dialog->getNr_von();Wie komme ich jetzt an meine Klassen Variabel ran? Mit dem Ansatz obendrüber funktioniert es nicht
Gruß Alex.
-
Probier mal
QString EingabeDialog::getNr_von(){ return Nr_von_LineEdit->text(); }Ansonsten: Falsches Forum