Zemy from blackberry forums answered me. Credit goes to him.
I think easiest is to pass the NavigationPane as a parameter from QML:
Q_INVOKABLE void function(NavigationPane *pane);
...
pane->push(homepage);
In QML:
_app.function(navPaneId)
But this got an error. Zemy again fixed it.
I've tried to reproduce this and also got the same error message. It seems NavigationPane isn't properly registered in Cascades.
Adding qmlRegisterType() fixed it:
ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
QObject(app)
{
// prepare the localization
m_pTranslator = new QTranslator(this);
m_pLocaleHandler = new LocaleHandler(this);
if(!QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()))) {
// This is an abnormal situation! Something went wrong!
// Add own code to recover here
qWarning() << "Recovering from a failed connect()";
}
// initial load
onSystemLanguageChanged();
//--------------------------------------
qmlRegisterType<NavigationPane>(); <---------------- ADDED
//--------------------------------------
// Create scene document from main.qml asset, the parent is set
// to ensure the document gets destroyed properly at shut down.
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_app", this);
// Create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// Set created root object as the application scene
app->setScene(root);
}