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

Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Overriding peek for customcontrol

[ Edited ]

All GUI controls inherit from BaseObject which has parent property. A possible solution is to find NavigationPane by iterating CustomControl's parents. This way it will work even when the control is deep in hierarchy of objects.


Untested code:


NavigationPane *MyControl::navigationPane()
  QObject *p = parent();
  while (p)
    NavigationPane *pane = qobject_cast<NavigationPane *>(p);
    if (pane != NULL)
      return pane;
    p = p->parent();
  return NULL;


NavigationPane *pane = navigationPane();
if (pane)

upd: actually QObject has parent property, BaseObject just exposes it to QML. So it's ok to use QObject in code above.


Andrey Fidrya, @zmeyc on twitter
Posts: 46
Registered: ‎03-25-2011
My Device: Blackberry Z10
My Carrier: KPN

Re: Overriding peek for customcontrol

What i did is creating a context class that has a static refrerence to the NavigationPane so that everywhere i am i can access the navpane by using Context::nav

so in youre case

main -> customcontrol1 -> customcontrol2 -> Context::nav->setPeekEnabled(bool);

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

Re: Overriding peek for customcontrol

[ Edited ]

Thanks guys appreciate the responses,


I think I'll give these a shot and see if any are suitable to my app.


Having tested this before Zmeys idea necessitates setting parent throughout the whole hierarchy and for my code at least with deeply hierarchical structures I often find parent is null at some point in the chain and therefore not guaranteed to work. At  least in my code that is.


Still a bug though. Smiley Wink

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.