Solved Detect when C++ method called from QML. How?
-
Hello all!
Is there any way to detect that method called from QML? I have the public slot that implemented in C++ class and it's might be called from QML and sometimes directly from C++.
The method C++ code:public slots: void mSomeMethod(sometype inSomeValue); ... pRootContext->setContextProperty("SomeObject",pSomeObject);
The calling from QML:
SomeObject.mSomeMethod(inSomeValue);
The calling from C++:
pSomeObject->mSomeMethod(inSomeValue);
The question is how to detect that method called from QML or C++? Is there any way without additional parameter?
-
@bogong said in Detect when C++ method called from QML. How?:
Is there any way without additional parameter?
No, you are calling a method from a C++ instance, like you would do it with any C++ instance.
You can also not know which C++ instance would call this method.If you need to know it, you have 2 options:
- add a parameter to describe source
- create a specific function for QML
-
@KroMignon Thx. Issue closed. Will do parameter like always.