<?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[anfängerfrage]]></title><description><![CDATA[<p>hi eine frage zu wertübergabe</p>
<p>ich habe mir eine klasse gebaut in der ich alle eingabewerte eines benutzers sammeln will....bis jetzt wird dort lediglich ein QString zwischen gespeichert</p>
<pre><code>#include &quot;data.hpp&quot;
using namespace std;
void Data::setPlPfad_slot(const QString &amp;pfad) {	
	plPfad = pfad;
	cout &lt;&lt; plPfad &lt;&lt; endl;
}

QString* Data::getPlPfad(){
	return &amp;plPfad;
}
</code></pre>
<p>dazu die header datei</p>
<pre><code>#ifndef DATA_HPP_
#define DATA_HPP_
#include &lt;qobject.h&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;qstring.h&gt;
using namespace std;
class Data : public QObject{
	Q_OBJECT
	public:
		Data(){};
		~Data(){};
		QString* getPlPfad();
		void coutpfad();	
	public slots:
		void setPlPfad_slot(const QString&amp;);		
	private:
		QString plPfad;	
};
#endif /*DATA_HPP_*/
</code></pre>
<p>in plPfad steht nach einer eingabe in ein textfeld auch was drin....hab ich getestet mit cout &lt;&lt; plPfad &lt;&lt; endl;</p>
<p>nun soll dieser pfad anderen classen zur verfügung stehen<br />
dafür soll getPlPfad() zuständig sein</p>
<pre><code>#include &quot;playlist.hpp&quot;

using namespace std;

void Playlist::reader_slot(){
	QString *pfad = data.getPlPfad();
	cout &lt;&lt; *pfad &lt;&lt; endl;	
}
</code></pre>
<pre><code>ifndef PLAYLIST_HPP_
#define PLAYLIST_HPP_
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;qstring.h&gt;
#include &lt;qobject.h&gt;
#include &quot;data.hpp&quot;
using namespace std;
class Playlist : public QObject{
	Q_OBJECT
	public:
		Playlist(){};
		~Playlist(){};				
	public slots:	
		void reader_slot();
	private:
		Data data;	
};
#endif /*PLAYLIST_HPP_*/
</code></pre>
<p>leider ist der pointer *pfad leer bzw. es wird kein pfad ausgegeben</p>
<p>was habe ich da falsch gemacht?</p>
<p>thx für die antworten</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/134394/anfängerfrage</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 16:26:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/134394.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Jan 2006 17:36:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to anfängerfrage on Wed, 25 Jan 2006 17:36:29 GMT]]></title><description><![CDATA[<p>hi eine frage zu wertübergabe</p>
<p>ich habe mir eine klasse gebaut in der ich alle eingabewerte eines benutzers sammeln will....bis jetzt wird dort lediglich ein QString zwischen gespeichert</p>
<pre><code>#include &quot;data.hpp&quot;
using namespace std;
void Data::setPlPfad_slot(const QString &amp;pfad) {	
	plPfad = pfad;
	cout &lt;&lt; plPfad &lt;&lt; endl;
}

QString* Data::getPlPfad(){
	return &amp;plPfad;
}
</code></pre>
<p>dazu die header datei</p>
<pre><code>#ifndef DATA_HPP_
#define DATA_HPP_
#include &lt;qobject.h&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;qstring.h&gt;
using namespace std;
class Data : public QObject{
	Q_OBJECT
	public:
		Data(){};
		~Data(){};
		QString* getPlPfad();
		void coutpfad();	
	public slots:
		void setPlPfad_slot(const QString&amp;);		
	private:
		QString plPfad;	
};
#endif /*DATA_HPP_*/
</code></pre>
<p>in plPfad steht nach einer eingabe in ein textfeld auch was drin....hab ich getestet mit cout &lt;&lt; plPfad &lt;&lt; endl;</p>
<p>nun soll dieser pfad anderen classen zur verfügung stehen<br />
dafür soll getPlPfad() zuständig sein</p>
<pre><code>#include &quot;playlist.hpp&quot;

using namespace std;

void Playlist::reader_slot(){
	QString *pfad = data.getPlPfad();
	cout &lt;&lt; *pfad &lt;&lt; endl;	
}
</code></pre>
<pre><code>ifndef PLAYLIST_HPP_
#define PLAYLIST_HPP_
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;string&gt;
#include &lt;qstring.h&gt;
#include &lt;qobject.h&gt;
#include &quot;data.hpp&quot;
using namespace std;
class Playlist : public QObject{
	Q_OBJECT
	public:
		Playlist(){};
		~Playlist(){};				
	public slots:	
		void reader_slot();
	private:
		Data data;	
};
#endif /*PLAYLIST_HPP_*/
</code></pre>
<p>leider ist der pointer *pfad leer bzw. es wird kein pfad ausgegeben</p>
<p>was habe ich da falsch gemacht?</p>
<p>thx für die antworten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976217</guid><dc:creator><![CDATA[copper]]></dc:creator><pubDate>Wed, 25 Jan 2006 17:36:29 GMT</pubDate></item><item><title><![CDATA[Reply to anfängerfrage on Wed, 25 Jan 2006 22:25:40 GMT]]></title><description><![CDATA[<p>Man sieht keinen Code in dem Du 'setPlPfad_slot' aufrufst; bzw. welche Variable dort als Parameter übergeben wird.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976437</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976437</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Wed, 25 Jan 2006 22:25:40 GMT</pubDate></item><item><title><![CDATA[Reply to anfängerfrage on Thu, 26 Jan 2006 12:08:11 GMT]]></title><description><![CDATA[<p>hi problem gelöst</p>
<p>ich hatte in playlist ne instanz von data aufgemacht ...diese enthält natürlich den wert der variable plpfad nicht ..wird ja ne neue angelegt ...ergo kein wert vorhanden</p>
<p>ich übergebe beim aufruf von playlist in</p>
<pre><code>#include &lt;qapplication.h&gt;
#include &lt;qpushbutton.h&gt;
#include &lt;qlayout.h&gt;
#include &lt;qlineedit.h&gt;
#include &lt;qslider.h&gt;
#include &lt;qlcdnumber.h&gt;
#include &quot;playlist.hpp&quot;
#include &quot;player.hpp&quot;
#include &quot;data.hpp&quot;
using namespace std;
int main(int argc, char *argv[])
{
    QApplication app(argc,argv);
    QWidget *mw = new QWidget();    

    QPushButton *q = new QPushButton(&quot;Quit&quot;, mw);
    QPushButton *p = new QPushButton(&quot;Play&quot;, mw);
    QPushButton *s = new QPushButton(&quot;Stop&quot;, mw);
    QLineEdit   *le= new QLineEdit(&quot;&quot;,mw); 
    QLCDNumber	*volValue = new QLCDNumber(mw);
    QLCDNumber	*posValue = new QLCDNumber(mw);    
    QSlider		*slidevol = new QSlider(mw);
    QSlider		*slidepos = new QSlider(mw);
    slidevol-&gt;setOrientation(Qt::Horizontal);
    slidevol-&gt;setCaption(&quot;Volume&quot;);
    slidepos-&gt;setOrientation(Qt::Horizontal);
    slidepos-&gt;setCaption(&quot;Position&quot;);
    volValue-&gt;setNumDigits(3);
    posValue-&gt;setNumDigits(30);

    Player *pl = new Player(slidevol,slidepos,volValue);
    Data *data = new Data();
    Playlist *playlist = new Playlist(data);

    QObject::connect(q,SIGNAL(clicked()),pl,SLOT(stop_slot()));    
    QObject::connect(q,SIGNAL(clicked()),&amp;app,SLOT(quit()));
    //QObject::connect(p,SIGNAL(clicked()),pl,SLOT(play_slot()));
    QObject::connect(p,SIGNAL(clicked()),playlist,SLOT(reader_slot()));
    QObject::connect(le,SIGNAL(textChanged(const QString&amp;)),data,SLOT(setPlPfad_slot(const QString&amp;)));
    QObject::connect(s,SIGNAL(clicked()),pl,SLOT(stop_slot()));    
    QObject::connect(slidevol,SIGNAL(valueChanged(int)),pl,SLOT(setVolume_slot(int)));    
    QObject::connect(slidepos,SIGNAL(valueChanged(int)),pl,SLOT(setPos_slot(int))); 
    QObject::connect(slidepos,SIGNAL(valueChanged(int)),posValue,SLOT(display(int)));

    QVBoxLayout *tl = new QVBoxLayout(mw);
    QHBoxLayout *bl = new QHBoxLayout();

    bl-&gt;addWidget(q);
    bl-&gt;addWidget(p);
    bl-&gt;addWidget(s);
    bl-&gt;addWidget(le);
    bl-&gt;addWidget(slidevol);    
    bl-&gt;addWidget(volValue);
    bl-&gt;addWidget(slidepos);
    bl-&gt;addWidget(posValue);
    tl-&gt;addLayout(bl);

    mw-&gt;setCaption(&quot;PlayerGui&quot;);
    mw-&gt;show(); 

    int result = app.exec();

    delete q;
    delete p;
    delete s;
    delete le;
    delete slidevol;
    delete slidepos;
    delete tl;
    delete bl;
    delete pl;
    delete playlist;
    delete data;
    delete volValue;
    delete posValue;

    return result;
}
</code></pre>
<p>der klasse playlist einen zeiger auf die instanz von data...ergo es wird mit ein und der selben variable gearbeitet</p>
<p>könnte man plPfad auch static machen? ...dann könnte man doch beliebig viele instanzen aufmachen und die werte sind immer gleich oder?</p>
<p>grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976846</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976846</guid><dc:creator><![CDATA[copper]]></dc:creator><pubDate>Thu, 26 Jan 2006 12:08:11 GMT</pubDate></item></channel></rss>