ReferenceError: xxx is not defined
-
Hi and welcome to devnet,
What exactly is xxx ?
-
@SGaist
It's exactly ReferenceError: xmlReaderCpp is not defined -
With current code what you pasted, you should to have this issue. This error clearly indicates that xmlReaderCpp is not defined when you load qml file. See your flow.
-
Using a modified main.qml because I don't have Felgo at hand.
Your code is working properly. Just beware that your property will return an invalid variant as you do not initialise
m_helloText
with any text.I'd recommend using a simple dummy qml file to get started just to check that you have everything working correctly with base types before going further.
-
With current code what you pasted, you should to have this issue. This error clearly indicates that xmlReaderCpp is not defined when you load qml file. See your flow.
@dheerendra But if I understand it right I using ctx->setContextProperty("xmlReaderCpp", &xmlReaderH) before loading any qml so I don't understand why xmlReaderCpp isn't defined.
-
It is not xmlReader is undefined. Error must be something else. Just copy paste the exact error.
Here your m_helloText is uninitialised. In the constructor you have initialised some other variable.
Please change the constructor statement to
m_helloText = = "Dheerendra";Then everything should work fine.
-
It is not xmlReader is undefined. Error must be something else. Just copy paste the exact error.
Here your m_helloText is uninitialised. In the constructor you have initialised some other variable.
Please change the constructor statement to
m_helloText = = "Dheerendra";Then everything should work fine.
@dheerendra I initialised m_helloText.
But I still got file:/untitled//main.qml:14: ReferenceError: xmlReaderCpp is not defined -
Did you try as I suggested with a simpler main.qml file ?
-
@SGaist yes I tried it but still nothing but maybe I managed it, I haven't try it yet because now I don't have time. Everything in my code is fine but there is a problem with Felgo.
For future viewers try this https://felgo.com/developers/forums/t/cant-integrate-c-in-qml. I will try it tomorrow and if it work I close this topic as solved.But still thanks for helping.
-
You can refer the example here.
I have taken the code from your sample & made it.