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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 92
Registered: ‎01-23-2009
My Device: Z10
My Carrier: klarmobil
Accepted Solution

NavigationPane and the topChanged SIGNAL

Could someone kindly explain why this

QObject::connect(this->navigation_pane, SIGNAL(topChanged(Page*)), this, SLOT(onTopPageChanged(Page*)));

 does not work while this

QObject::connect(this->navigation_pane, SIGNAL(topChanged(bb::cascades::Page*)), this, SLOT(onTopPageChanged(bb::cascades::Page*)));

 does?

Developer
Posts: 293
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: NavigationPane and the topChanged SIGNAL

It's a namespace issue -

In the top example the compiler does not understand what a Page is because it doesn't appear in the c++ global namespace. Page can be found in the bb::cascades namespace, which is why your second example works.

Just write:

using namespace bb::cascades;

in each .cpp file that you want to reference cascades objects and classes
Highlighted
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: NavigationPane and the topChanged SIGNAL

[ Edited ]

MOC (meta-object compiler) doesn't take presence of namespaces into account. It compares argument types as strings. As the enums are defined as fully-qualified in Cascades headers they should also be fully-qualified in connect() calls. If they weren't fully-qualified clashes could occur for enums with same names in different classes.

 

From Qt docs:

 

Enums and Typedefs Must Be Fully Qualified for Signal and Slot Parameters

 

When checking the signatures of its arguments, QObject::connect() compares the data types literally. Thus, Alignment and Qt::Alignment are treated as two distinct types. To work around this limitation, make sure to fully qualify the data types when declaring signals and slots, and when establishing connections.

 

p.s. About the class names:

Names registered in qRegisterMetaType should be fully qualified otherwise they won’t be recognized by qvariant_cast. Cascades use fully-qualified class names so they should also be fully-qualified in signals declaration. 'using namespace' won't help with signal arguments, MOC will ignore it.

 

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 293
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: NavigationPane and the topChanged SIGNAL

Zmey has the correct answer!
New Developer
Posts: 92
Registered: ‎01-23-2009
My Device: Z10
My Carrier: klarmobil

Re: NavigationPane and the topChanged SIGNAL

@strobejb Of cause I have "using namespace bb::cascades;" declared. Otherwise it would just result in a compile error. No, both versions compile, the difference is only noticable at runtime.