Solved Signal and Slots
-
Hi @Bhushan_Sure,
Did you set your
gooooo
object as a context property of the Qml engine ?Abc gooooo; //... engine.rootContext()->setContextProperty("gooooo", &gooooo); //...
-
@Gojir4 yes , i did that.
-
@Nikhilesh-N
No, in abc.cpp ? -
@Bhushan_Sure Can we see the definition of the class Abc ? Especially the
complete
signal ? -
@Bhushan_Sure
Yes, you need to have a header file of abc that inherits from QObject. In that class you may create a Q_PROPERTY, and register this class using qmlRegisterType in main.cpp file.
Then you can create an object of abc class on the QML side, where you can catch your signal. -
@Nikhilesh-N ok i will try this.
Could you tell me what will here
Be signal and slot and object
In Q_property syntax ? -
@Gojir4 ok
I will post that class tomorrow as i m out of office now ! -
@Nikhilesh-N The goal is not to create the object from QML side, as it is "shared" as a QML context property, but only to catch the signal. So, at my opinion, there is no need to use Q_PROPERTY or to register the type at all.
You could make a
complete
property, and then use the "onCompleteChanged" signal from QML. But why using a property if a signal is enough to notify the QML side ? -
@Bhushan_Sure Either you have missed registering the your goose object 'gooooo' before loading the qml. Just check whether you have defined the complete signal. Is it defined with capital letters ? Hope all the methods in abc.cpp are defined with scope resolution.
-
@Gojir4 If that is the case, your solution of using a context property is good and will suffice.
@Bhushan_Sure If you folow Gojir4's solution, you can emit your signal via C++ and catch it via QML in a Connections object without any issues. Either this, or you also can emit your signal through QML in order to catch it there.
-
@Nikhilesh-N @dheerendra @Gojir4
Hi i Solved the problem, From JNI function i was creating new object and then calling function,Jnifunction { //the java is returning to JNI function from here i am calling status function classobject.status(status); }
instead of that i used same instance of object and called it and the problem got solved.
-
It was issue of different objects ?
-
@dheerendra yes sir, Sir how to solved this issue if i have to use different object and not the same instance.
-
practically this case should not arise. If you can show me the simple code sample, I can help you.