未定义的引用`Person :: customerIDChanged(QString const&)'

时间:2013-07-24 10:59:37

标签: c++ qml blackberry-10

我更喜欢黑莓开发。我正在创建一个简单的Person类,其中.cpp和.hpp文件的firstName,customerId,address作为class的成员。我创建了Properties和setter,getters,但是它给出了错误Person.cpp,Setters定义,当我尝试发出在Person.hpp中声明的信号时。

错误:未定义引用`Person :: customerIDChanged(QString const&)'

Person.cpp:

void Person::setCustomerID(const QString &newId)
{
    if (newId != m_id) {
        m_id = newId;
        emit customerIDChanged(newId); // gives error at this line
    }
}

void Person::setFirstName(const QString &newName)
{
    if (newName != m_firstName) {
        m_firstName = newName;
        emit firstNameChanged(newName);// gives error at this line
                }
}
void Person::setAddress(const QString &newName){

if (newName != m_address) {
 m_address = newName;
 emit addressChanged(m_address);// gives error at this line
   }}

Person.hpp:

class Person:public QObject
{ 
    Q_OBJECT

Q_PROPERTY( QString customerID READ customerID WRITE setCustomerID NOTIFY customerIDChanged FINAL)

   Q_PROPERTY( QString firstName READ firstName WRITE setFirstName NOTIFY firstNameChanged FINAL)

   Q_PROPERTY( QString address READ address WRITE setAddress NOTIFY addressChanged FINAL)

public:

  Person(QObject *parent = 0): QObject(parent){};

  Person(const QString &id, const QString &firstname, const QString &address, QObject *parent = 0) : QObject(parent)
   , m_id(id)
   , m_firstName(firstname)
   , m_address(address){};

  QString customerID() const;
  QString firstName() const;
  QString address() const;

  void setCustomerID(const QString &newId);
  void setFirstName(const QString &newName);
  void setAddress(const QString &newName);

Q_SIGNALS:

void customerIDChanged(const QString &newId);
void firstNameChanged(const QString &firstName);
void addressChanged(const QString &address);

private:

    QString m_id;
    QString m_firstName;
    QString m_address;};
#endif

Thanx提前!!

0 个答案:

没有答案