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
mmarion
Posts: 58
Registered: ‎05-03-2013
My Device: Z10
My Carrier: Rogers
Accepted Solution

container touch

I hope it's not a dumb question:

 

I am trying to catch some container's touch, touchEnter and touchExit signals.

 

I have:

 

class Example: public QObject {

    Q_OBJECT
public:
    Example();
    virtual ~Example();

 

signals:

...

public slots:

    void touch(bb::cascades::TouchEvent * event);

 

private:

...

};

 

I'm trying to connect the container's touch to my touch:

 

bool result = connect(example_container,SIGNAL(touch(TouchEvent*)),this,SLOT(touch(TouchEvent*)));
Q_ASSERT(result);

 

But it tells me that neither example_container nor this' touch is a signal/slot.  I look up the docs:

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__container.html#function-tou...

 

Looks like a slot to me not to mention mine is in the slots section of the header.

 

Any idea what I'm doing wrong here?

Please use plain text.
Developer
BBSJdev
Posts: 6,094
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: container touch

Can you post the code where you define example_container leading to the connection code?


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

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: container touch

[ Edited ]

Hi,
Type names inside of SIGNAL() and SLOT() macros should be fully-qualified. MOC can't resolve namespaces.

 

And just to be safe, I suggest using a different name for the slot, for example onTouch. This isn't required, but avoids conflicts if you declare a signal with this name or inherit from a class where the signal is declared.

bool result = QObject:::connect(container, SIGNAL(touch(bb::cascades::TouchEvent*)), this, SLOT(onTouch(bb::cascades::TouchEvent*)));

 

public slots:

    void onTouch(bb::cascades::TouchEvent * event);


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
mmarion
Posts: 58
Registered: ‎05-03-2013
My Device: Z10
My Carrier: Rogers

Re: container touch

I figured out my issue which was a combinatin of a few things:

 

1. When I tried with fully qualified names (bb::cascades::TouchEvent *) I also had the variable name so it failed. 

2. When I checked another example I had which used QString it didn't have bb::cascades:: and I never made the connection (doesn't have to with QString).  I went and removed both the variable name and bb::cascades::

 

My bad.  I figured there was something obvious there that I missed.  The most embarassing part is that I've used fully qualified names for widget pointers in slots many times already, just had a brain fart.  Thanks for putting me back on track.

Please use plain text.