Qml + Qt Class communication
-
Hi!
I have the follow code:
//bike.qml
@
Bike
{
Component.onCompleted : getStuff()
}
@
// Bike.h
@
class Bike: public QObject
{
Q_OBJECT
public:
Q_INVOKABLE void getStuff();
}
@
// Bike.cpp
@
void Bike::getStuff()
{
// do something
}
@
In main I registered the class...The problem is.. On runtime it gives me a error "no variable founded" pointing to "getStuff" on QML file...
What i'm doing wrong?
[Edit: Added @-tags for code formatting; mlong]
-
You should have registered the class with an identifier somehow.
In that case, you would use
@
Component.onCompleted: something.getStuff()
@ -
But.. I want to use the function.. as i use the proprieties....
-
There's no "getStuff" invokable function or slot defined in your Bike class.
/edit: I meant declared, obviously. -
@chriadam : Ok... a small mistake... but that is not the problem... :-(
-
Ok :-D
Today, with a "fresh head" :) I resolved the problem!
Problem: A wrong Copy & past ... provokes a qmlRegisterType bad writed!