<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Variabel Zugriff von anderer Klasse (QT)]]></title><description><![CDATA[<p>Hallo Commnuity,</p>
<p>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.</p>
<p>Dialog Header:</p>
<pre><code class="language-cpp">#ifndef EINGABEDIALOG_H
#define EINGABEDIALOG_H

#include &lt;QtGui&gt;

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_H
</code></pre>
<p>Dialog CPP</p>
<pre><code class="language-cpp">#include &quot;eingabedialog.h&quot;
#include &quot;ui_eingabedialog.h&quot;

EingabeDialog::EingabeDialog(QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::EingabeDialog){

    m_ui-&gt;setupUi(this);

    Nr_von_LineEdit = new QLineEdit;
    Nr_von_LineEdit = m_ui-&gt;Baunummer_von;
    Nr_von_LineEdit-&gt;setInputMask(&quot;999&quot;);

    ButtonBox = new QDialogButtonBox;
    ButtonBox = m_ui-&gt;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-&gt;text();
}
</code></pre>
<p>Main Widget</p>
<pre><code class="language-cpp">EingabeDialog *in_Dialog = new EingabeDialog(this);
    QString ausgabe = in_Dialog-&gt;getNr_von();
</code></pre>
<p>Wie komme ich jetzt an meine Klassen Variabel ran? Mit dem Ansatz obendrüber funktioniert es nicht</p>
<p>Gruß Alex.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/252937/variabel-zugriff-von-anderer-klasse-qt</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 04:54:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/252937.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Oct 2009 16:24:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Variabel Zugriff von anderer Klasse (QT) on Mon, 26 Oct 2009 16:24:43 GMT]]></title><description><![CDATA[<p>Hallo Commnuity,</p>
<p>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.</p>
<p>Dialog Header:</p>
<pre><code class="language-cpp">#ifndef EINGABEDIALOG_H
#define EINGABEDIALOG_H

#include &lt;QtGui&gt;

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_H
</code></pre>
<p>Dialog CPP</p>
<pre><code class="language-cpp">#include &quot;eingabedialog.h&quot;
#include &quot;ui_eingabedialog.h&quot;

EingabeDialog::EingabeDialog(QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::EingabeDialog){

    m_ui-&gt;setupUi(this);

    Nr_von_LineEdit = new QLineEdit;
    Nr_von_LineEdit = m_ui-&gt;Baunummer_von;
    Nr_von_LineEdit-&gt;setInputMask(&quot;999&quot;);

    ButtonBox = new QDialogButtonBox;
    ButtonBox = m_ui-&gt;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-&gt;text();
}
</code></pre>
<p>Main Widget</p>
<pre><code class="language-cpp">EingabeDialog *in_Dialog = new EingabeDialog(this);
    QString ausgabe = in_Dialog-&gt;getNr_von();
</code></pre>
<p>Wie komme ich jetzt an meine Klassen Variabel ran? Mit dem Ansatz obendrüber funktioniert es nicht</p>
<p>Gruß Alex.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798664</guid><dc:creator><![CDATA[Alex67071]]></dc:creator><pubDate>Mon, 26 Oct 2009 16:24:43 GMT</pubDate></item><item><title><![CDATA[Reply to Variabel Zugriff von anderer Klasse (QT) on Mon, 26 Oct 2009 16:31:13 GMT]]></title><description><![CDATA[<p>Probier mal</p>
<pre><code class="language-cpp">QString EingabeDialog::getNr_von(){
    return Nr_von_LineEdit-&gt;text();
}
</code></pre>
<p>Ansonsten: Falsches Forum</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1798669</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1798669</guid><dc:creator><![CDATA[MiP]]></dc:creator><pubDate>Mon, 26 Oct 2009 16:31:13 GMT</pubDate></item></channel></rss>