TypeError: Object [object Object] has no method 'sendData'
qml file:
Code:
onClicked:
{
Sender.address = "udpm://239.255.76.67:7687"
Sender.ttl= 0
Sender.channel= "A"
Sender.data= "ddfdsf"
Sender.sendData()
}
.h file:
Code:
Q_INVOKABLE void sendData ();
main.cpp file:
Code:
int main (int argc, char *argv[])
{
QGuiApplication app(argc, argv);
const char* ocuui = "OCUUI"; // @uri OCUUI
qmlRegisterType <Sender> (ocuui, 1, 0, "Sender");
Sender objS;
objS.sendData ();
QtQuick2ApplicationViewer viewer;
viewer.addImportPath("/home....");
viewer.setMainQmlFile(QStringLiteral("..../main.qml"));
viewer.showExpanded();
return app.exec();
}
I am using QtCreator. The thing I find odd is that when I type it shows a list of the members of that class and that list "contains" sendData function.
What point am I missing? Yes, sendData has been defined in the corresponding .cpp file.
Re: TypeError: Object [object Object] has no method 'sendData'
You register a type called "Sender", but you don't seem to have an obect of that type.
Did you want to export the Sender instance objS? In that case look for QQmlContext::setContextProperty()
Cheers,
_
Re: TypeError: Object [object Object] has no method 'sendData'
Quote:
Originally Posted by
anda_skoa
You register a type called "Sender", but you don't seem to have an obect of that type.
_
That was the exact problem. Thank much.