[Kde-finance-apps] Problem Using getter and Setter Function

Mukesh Gupta mukesh.gupta2011 at ece.dce.edu
Wed Jun 23 15:41:50 CEST 2010


Hello Friends,
I am trying to use getter and setter functions in my class but facing a
problem. My code goes as follows;

*AlkRecord.h
*
...
....
Class Alkrecord
{
....
public:

Q_PROPERTY(QString source READ source WRITE setsource);
//setter function
void setsource (const QString& source)
{
    m_source=source;
}

//getter function
 QString source() const
 {
         return m_source;
 }

private:
.....
QString  m_source;
.....
};



*AlkRecord.cpp*

.......
......
AlkRecord::AlkRecord(QString const& Src, QString const& Memo, QString const&
Amount)
{
  ........
 *source= Src;*
.......
}


The error  is as follows:

*error: invalid use of member (did you forget the ‘&’ ?)
*This error is in the line shown in bold

Shouldn't the setter function be called when i try to assing source with
some value.
Also how do i get the value of m_variable using getter function.

Please help.

Regards,
Mukesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-finance-apps/attachments/20100623/bd464a79/attachment.htm 


More information about the Kde-finance-apps mailing list