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
Contributor
Posts: 17
Registered: ‎03-28-2012
My Device: Developing on multiple models
My Carrier: Multiple providers

QObject (and Signals and Slots) in static library

Hi,

 

I am developing a static library which will be included in a caccades application. In the static library I want to use the SIGNALS and slots.

 

The problem is for example if I have the following class:

class MyLibClass:public QObject{
  Q_OBJECT
  public:
    void aMethod();
  public slots:
    void aSlot();
}

 and when I include the library in my cascade app, I get linker error when compiling. I understand this is because of the Q_OBJECT macro which has not been procecced by qmake in my static library project. But I dont know how to run qmake before the qcc.

 

What is the standard (and easiest) way of having the signal/slot handling in me shared library?

 

Please let me know if I am missing any information in this regard.

 

Thanks

 

Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: QObject (and Signals and Slots) in static library

Is that all the code of your class?

 

Try this if so:

#include <QObject>

class MyLibClass:public QObject{
	Q_OBJECT

	public:
		MyLibClass(QObject *parent=0) : QObject(parent) { }
		void aMethod();

	public slots:
		void aSlot();
}

 I'm not sure what the problem is if this does not resolve your problem.

______________________________________________________
BB10-OAuth: GitHub
Highlighted
Contributor
Posts: 17
Registered: ‎03-28-2012
My Device: Developing on multiple models
My Carrier: Multiple providers

Re: QObject (and Signals and Slots) in static library

Thanks Curahee. I did not want to bore people with all the code I wrote. Besides my project is quite large to be shared here. That's why I gave a cut down version. Moreover, this seems to be a spoken over subject. Had I not included

#include <QObject>

it would have failed during compilation and I wouldn't have progressed up to the linking stage.