Search code examples
c++qtblackberryblackberry-10

Signal-Slot for TabbedPane Blackberry 10


I'm a newbie to Blackberry 10 development and the whole qt signal-slot mechanism. I am trying to register a signal and slot for when a user clicks on a different tab in my Blackberry 10 native application. I have the following code for my UI:

TabbedPane {
    id: mainTabbedPane
    showTabsOnActionBar: true
    peekEnabled: true
    sidebarState: SidebarState.VisibleFull
    Tab { 
        ...
    } //End of first tab
    Tab { 
        ...
    } //End of second tab
    ...

applicationui.cpp

AbstractPane *appPane = qmlDocument->createRootObject<AbstractPane>();

    if (appPane) {
        // Set the main application scene to NavigationPane.
        Application::instance()->setScene(appPane);
    }

    TabbedPane* tabbedPane = appPane->findChild<TabbedPane*>("mainTabbedPane");
    qDebug("Pane: %p", tabbedPane);

    QObject::connect(tabbedPane, SIGNAL(activeTabChanged(bb::cascades::Tab*)), SLOT(sectionTriggered(bb::cascades::Tab*)));

My issue is that it seems the TabbedPane is not being found despite being in the UI. What I'm I doing wrong? Also, I'm I implementing the signal-slot correctly?

Thank you in advance.


Solution

  • You could also use onTriggered in QML, so you can get that this way. Depends on what you want

    Tab {
         title: "Tab name"
         onTriggered: {
    
         }
     },
    

    BUT to fix your problem directly, you're missing objectName

    TabbedPane {
        id: mainTabbedPane
        objectName: "mainTabbedPane"
        showTabsOnActionBar: true
        peekEnabled: true
        sidebarState: SidebarState.VisibleFull
        Tab { 
            ...
        } //End of first tab
        Tab { 
            ...
        } //End of second tab