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
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
Accepted Solution

Newbie QT question about ::connect

Hi everybody,

 

I started working on my first Cascades app, but I ran into a bit of a mystery (at least to me). I have this code:

 

App::App(bb::cascades::Application *app)
: QObject(app)
{
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    app->setScene(root);

    //Initiate managers
    dataManager = new DataManager();

    //Fetch scan button
    Button* scanButton = root->findChild<Button*>("scanButton");
    if(scanButton)
    {
    	QObject::connect(scanButton, SIGNAL(clicked()), dataManager, SLOT(handleScanEvent()));
    }
}

 When trying to compile I get this error:

 

../src/App.cpp:27:90: error: no matching function for call to 'App::connect(bb::cascades::Button*&, const char*, DataManager*&, const char*)'
../src/App.cpp:27:90: note: candidates are:
/Applications/bbndk/target_10_0_9_386/qnx6/usr/include/qt4/QtCore/qobject.h:204:17: note: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
/Applications/bbndk/target_10_0_9_386/qnx6/usr/include/qt4/QtCore/qobject.h:204:17: note:   no known conversion for argument 3 from 'DataManager*' to 'const QObject*'
/Applications/bbndk/target_10_0_9_386/qnx6/usr/include/qt4/QtCore/qobject.h:217:17: note: static bool QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType)
/Applications/bbndk/target_10_0_9_386/qnx6/usr/include/qt4/QtCore/qobject.h:217:17: note:   no known conversion for argument 2 from 'const char*' to 'const QMetaMethod&'
/Applications/bbndk/target_10_0_9_386/qnx6/usr/include/qt4/QtCore/qobject.h:337:13: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
/Applications/bbndk/target_10_0_9_386/qnx6/usr/include/qt4/QtCore/qobject.h:337:13: note:   no known conversion for argument 3 from 'DataManager*' to 'const char*'
cc: /Applications/bbndk/host_10_0_9_52/darwin/x86/usr/lib/gcc/arm-unknown-nto-qnx8.0.0eabi/4.6.3/cc1plus error 1

 I don't see the difference with the Cascades tutorial... I am using the latest SDK. Can anyone point out the error? Thank you in advance.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: Newbie QT question about ::connect

Problem solved: I forgot to make DataManager a subclass of QObject.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!