Hello Cristian,Thomas,<br><br>Thanks for reply.What i was trying to do is access/set all member varibales using getter/setter functions. <br>I knew how to define the functions but did not know how to access them. I was confused whether to use them as normal functions or these could be used as variable after setting the property as thomas pointed out. Well, this is clear now.<br>
Thanks,<br>Regards,<br>Mukesh<br><br><div class="gmail_quote">On Wed, Jun 23, 2010 at 7:24 PM, Cristian Onež <span dir="ltr">&lt;<a href="mailto:onet.cristian@gmail.com">onet.cristian@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Wed, Jun 23, 2010 at 4:41 PM, Mukesh Gupta<br>
&lt;<a href="mailto:mukesh.gupta2011@ece.dce.edu">mukesh.gupta2011@ece.dce.edu</a>&gt; wrote:<br>
&gt; Hello Friends,<br>
&gt; I am trying to use getter and setter functions in my class but facing a<br>
&gt; problem. My code goes as follows;<br>
&gt;<br>
&gt; AlkRecord.h<br>
&gt;<br>
&gt; ...<br>
&gt; ....<br>
&gt; Class Alkrecord<br>
&gt; {<br>
&gt; ....<br>
&gt; public:<br>
&gt;<br>
&gt; Q_PROPERTY(QString source READ source WRITE setsource);<br>
&gt; //setter function<br>
&gt; void setsource (const QString&amp; source)<br>
&gt; {<br>
&gt; &nbsp;&nbsp;&nbsp; m_source=source;<br>
&gt; }<br>
&gt;<br>
&gt; //getter function<br>
&gt; &nbsp;QString source() const<br>
&gt; &nbsp;{<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return m_source;<br>
&gt; &nbsp;}<br>
&gt;<br>
&gt; private:<br>
&gt; .....<br>
&gt; QString&nbsp; m_source;<br>
&gt; .....<br>
&gt; };<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; AlkRecord.cpp<br>
&gt;<br>
&gt; .......<br>
&gt; ......<br>
&gt; AlkRecord::AlkRecord(QString const&amp; Src, QString const&amp; Memo, QString const&amp;<br>
&gt; Amount)<br>
&gt; {<br>
&gt; &nbsp; ........<br>
&gt; &nbsp;source= Src;<br>
&gt; .......<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; The error&nbsp; is as follows:<br>
&gt;<br>
&gt; error: invalid use of member (did you forget the &lsquo;&amp;&rsquo; ?)<br>
&gt; This error is in the line shown in bold<br>
&gt;<br>
&gt; Shouldn&#39;t the setter function be called when i try to assing source with<br>
&gt; some value.<br>
&gt; Also how do i get the value of m_variable using getter function.<br>
<br>
</div></div>Hi,<br>
<br>
I think I know what you are trying to do here but I don&#39;t quite get it<br>
why did you thought to write it that way. If you want m_source to get<br>
the value Src you should just write:<br>
<br>
m_source = Src;<br>
<br>
or using the setter<br>
<br>
setSource(Src);<br>
<br>
&#39;source&#39; get&#39;s you the address of the member function and you are<br>
trying to assign a string to it.<br>
<br>
BTW: variables usually start with lover case in the convention we use.<br>
<br>
Regards,<br>
Cristian<br>
_______________________________________________<br>
Kde-finance-apps mailing list<br>
<a href="mailto:Kde-finance-apps@kde.org">Kde-finance-apps@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kde-finance-apps" target="_blank">https://mail.kde.org/mailman/listinfo/kde-finance-apps</a><br>
</blockquote></div><br>