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

Reply
Developer
Posts: 96
Registered: ‎10-06-2012
My Device: Z10
My Carrier: Rogers

C++ injection to QML NavigationPane

Hey everyone, this is my first post so go easy on me

 

I'm looking at src of Kakel, Weatherguesser and the website for C++ QML integration. Pretty much understand how it's working and managed to replicate the work...

 

Problem  - I can only get it working when using main.qml and not on a navigation pane page

 

If I have "playAreaContainer" anywhere on the actual tabbed qml file (main.qml) injecting a component works.

BUT when "playAreaContainer" is on one of the NavigationPane stack injecting fails.

 

The weatherguesser does something similar but uses datamodels and I wanted a simpler example

 

Any help?

        mQmlDocument = QmlDocument::create("asset:///main.qml");
	mQmlDocument->setParent(this);
	mQmlDocument->setContextProperty("wordsPlus", this);

	if (!mQmlDocument->hasErrors()) {

		// The application navigationPane is created from QML.
		TabbedPane *tabs = mQmlDocument->createRootObject<TabbedPane>();
		mRootContainer = tabs->findChild<Container*>("playAreaContainer");

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

 

void WordsPlus::injectContainer()
{
	qDebug() << "Inside injectContainer - C++";
        mRootContainer->add(Container::create()
          .background(Color::Red)
          .preferredSize(200,200)
          .bottomMargin(20)
          .horizontal(HorizontalAlignment::Center));
}

 

 

Jason I. Carter
Follow me @jasonicarter
Built For BlackBerry - WordsPlus & WordsPlus: Free Edition | word search has never had it so good
www.twocasualcoders.com | never casual on quality