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: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Change the default font

Wait. Do I need a qml documents root object to be in the scene graph before I can use findChild?
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Change the default font

Yes findChild() only searches the current Scene Graph so the Object/Componant needs to have been placed or loaded in to the scene before findChild() will work.

 

More precisely the findChild function only searches the child objects within a QObject which of course needs to have been instantiated.

 


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.
Developer
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Change the default font

So, this code won't work?

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
TextStyle style = qml->findChild<TextStyle>("myCustomStyle");
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Change the default font

If you have attached a TextStyle within main.qml and it has an ObjectName of myCustomStyle then yes this would work.

 


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.
Developer
Posts: 123
Registered: ‎09-18-2013
My Device: Dev Alpha B
My Carrier: BSNL INDIA

Re: Change the default font

Thanks. That would be enough for me. Smiley Happy