Hello Friends,<br>I am trying to use getter and setter functions in my class but facing a problem. My code goes as follows;<br><br><b>AlkRecord.h<br></b><br>...<br>....<br>Class Alkrecord<br>{<br>....<br>public: <br><br>Q_PROPERTY(QString source READ source WRITE setsource);<br>
//setter function<br>void setsource (const QString& source)<br>{<br> m_source=source;<br>}<br><br>//getter function<br> QString source() const<br> {<br> return m_source;<br> }<br><br>private:<br>.....<br>QString m_source;<br>
.....<br>};<br><br><br><br><b>AlkRecord.cpp</b><br><br>.......<br>......<br>AlkRecord::AlkRecord(QString const& Src, QString const& Memo, QString const& Amount)<br>{<br> ........<br> <b>source= Src;</b><br>....... <br>
}<br><br><br>The error is as follows:<br><br><b>error: invalid use of member (did you forget the & ?) <br></b>This error is in the line shown in bold<br><br>Shouldn't the setter function be called when i try to assing source with some value.<br>
Also how do i get the value of m_variable using getter function.<br><br>Please help.<br><br>Regards,<br>Mukesh<br><br><br><br><br><br><br>