02-07-2013 12:32 AM
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?
Solved! Go to Solution.
02-07-2013 01:43 AM
02-07-2013 01:48 AM - edited 02-07-2013 01:57 AM
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.
02-07-2013 02:07 AM
02-07-2013 02:08 AM
@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.