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
New Developer
laxad
Posts: 24
Registered: ‎12-08-2012
My Device: Z10 Ferrari Red

no matching function for call to findChild

I am trying to access one of the QML elements using C++ code. I have read a lot of forums and the developer guide - specifically the part on how to make QML and C++ work together.

 

This is my code:

 

    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    ListView *listView = root->findChild<ListView*>("eventsList");
    listView->setDataModel(groupDataModel);

 

And I get ...


error: no matching function for call to 'bb::cascades::AbstractPane::findChild(const char [11])'
candidate is: /Applications/bbndk/target_10_0_9_1101/qnx6/usr/include/qt4/QtCore/qobject.h:158:14: note: template<class T> T QObject::findChild(const QString&) const

The above code is the recommended way to get QML element from what I read.

Any help on this would be appreciated.

 

Thank you,

Dax

Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: no matching function for call to findChild

make sure you have the appropriate classes and namespaces imported and in use, that would cause it to complain about T since it wouldnt know that it was a valid argument.
Like all of my posts
Please use plain text.
New Developer
laxad
Posts: 24
Registered: ‎12-08-2012
My Device: Z10 Ferrari Red

Re: no matching function for call to findChild

I have created the default empty project template from Momentics IDE (Beta 4) and added the one line below:

 

    ListView *listView = root->findChild<ListView*>("eventsList");

 

With the default empty project template, how can I get an error?
I have the default imports:

 

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>

 

using namespace bb::cascades;

 

Are there additional imports/namespaces I need to add to this?

Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: no matching function for call to findChild

#include <bb/cascades/ListView>
Like all of my posts
Please use plain text.