Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 17
Registered: ‎01-09-2014
My Device: BB10
My Carrier: Airtel
Accepted Solution

How to generate .moc file

Hi All,

 

I am getting 1 problem i.e. unable to compile my class. It is showing me error as:

"undefined reference to `SubCategoryListObject::notifyCatNameChanged()'"

 

My .h and .cpp classes are as follows:

 

.h:

/*

* SubCategoryListObject.h

*

*  Created on: 17-Apr-2014

*/

#ifndef SUBCATEGORYLISTOBJECT_H_

#define SUBCATEGORYLISTOBJECT_H_

 

#include <SubCategory.h>

 

#include <QtCore>

#include <QObject>

 

#include <bb/cascades/QListDataModel>

#include <bb/cascades/DataModel>

 

class SubCategoryListObject : public QObject {

Q_PROPERTY(QString catName READ getCatName NOTIFY notifyCatNameChanged)

 

public:

    SubCategoryListObject(SubCategory* subCatObj, QObject* parent = 0);

    virtual ~SubCategoryListObject();

 

Q_SIGNALS:

    void notifyCatNameChanged();

 

private:

    SubCategory* subCategoryObj;

    QString _catName;

 

    QString getCatName() const {

        return (_catName);

    }

};

 

#endif /* SUBCATEGORYLISTOBJECT_H_ */

 

 

.cpp:

 

/*

* SubCategoryListObject.cpp

*

*  Created on: 17-Apr-2014

*/

 

#include "SubCategoryListObject.h"

#include "CommonFunctions.h"

 

#include <QtCore>

#include <QObject>

 

#include "SubCategory.h"

 

SubCategoryListObject:Smiley FrustratedubCategoryListObject(SubCategory* _subCategoryObj, QObject* parent) :

        QObject(parent), subCategoryObj(_subCategoryObj) {

    // Set SubCategory Name

    _catName = subCategoryObj->getSubStoreTypeName();

 

    emit notifyCatNameChanged(); // Here, I am getting error

}

 

SubCategoryListObject::~SubCategoryListObject()

{

    // TODO Auto-generated destructor stub

}

 

 

WHEN I gone through the following link, I found that 'moc' file is not generated for me also.

http://stackoverflow.com/questions/17832033/undefined-reference-to-personcustomeridchangedqstring-co...

 

Please suggest me how to make changes in Project Properties or anything else, so that I will be able to compile my code.

 

Thanks in advance.

Retired
Posts: 85
Registered: ‎05-25-2012
My Device: Limited Edition Z10
My Carrier: Bell

Re: How to generate .moc file

You are missing Q_OBJECT in the class declaration:

 

class SubCategoryListObject : public QObject {
Q_OBJECT
Q_PROPERTY(QString catName READ getCatName NOTIFY notifyCatNameChanged)

 

Highlighted
Developer
Posts: 17
Registered: ‎01-09-2014
My Device: BB10
My Carrier: Airtel

Re: How to generate .moc file

Hi, I have tried to use 'Q_OBJECT' as you mentioned but unfortunately it is not working.

 

After using it, it is giving me error in .cpp file and error is:

'undefined reference to `vtable for SubCategoryListObject' in constructor and destructor of same class.

AND

'undefined reference to `SubCategoryListObject::notifyCatNameChanged()' still exists. 

 

But I find again that it is not generating that required 'moc' file.

 

Should I make changes in Project Properties?

Please give me any solution or let me know if you need any content from my side.

 

Thanks for your reply.

 

 

Retired
Posts: 85
Registered: ‎05-25-2012
My Device: Limited Edition Z10
My Carrier: Bell

Re: How to generate .moc file

Have you tried cleaning the project?  I copied the above code (with the Q_OBJECT added to the class header file) and it compiled fine.

 

Developer
Posts: 17
Registered: ‎01-09-2014
My Device: BB10
My Carrier: Airtel

Re: How to generate .moc file

Hi erahnenfuehrer,

 

Please check that whether it is generating 'moc' file in your code.

If so, can you please specify any specific PROJECT PROPERTIES.

 

I have attached following images for 'Project -> Properties -> C/C++ Build' -> Builder Settings AND Behaviour in my IDE.

 Builder Setttings.pngBehaviour.png

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to generate .moc file

It looks like either your IDE didn't install correctly or you haven't started with a BlackBerry project as you are missing the BlackBerry elements in your screen shots.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 17
Registered: ‎01-09-2014
My Device: BB10
My Carrier: Airtel

Re: How to generate .moc file

Can you please specify that which BB elements OR options are missing in mine.

And how can I get them again??

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to generate .moc file

The BlackBerry API level for a start.

 

Did you specify a BlackBerry project when you first started?

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to generate .moc file

If you create a new project using one of the examples/samples does it build correctly?

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 17
Registered: ‎01-09-2014
My Device: BB10
My Carrier: Airtel

Re: How to generate .moc file

Yes BBSJdev.

 

I have tried with 'imageloader' and 'pullmybeard' samples.

These are working fine.

 

But when I am trying to use my files - 'SubCategoryListObject',

the same error occurs as I mentioned i.e. "undefined reference to `SubCategoryListObject::notifyCatNameChanged()"

 

Also, my project is a BB project.

 

Might be there is any problem with 'Project Properties' or 'Window Preferences'. I am not sure what exactly it is??