If I pass an object to a QML and that object in turn grabs another object I error out with the following:
"code example/main.js:4: TypeError: Result of expression 'failedObject' [undefined] is not an object."
Now if I change line 16 in object1.h (and of course its matching function in object1.cpp) to QObject the script will convert it fine and I will not have any errors. The problem with this is I then have to qobject_cast when using the function internally in the c++ code. This casting internally just to get it to be recognized correctly in the script feels wrong to me.
Since my class inherits QObject I was under the impression I should not have to use qRegisterMetaType. It appears to be registered correctly since it knows how to cast it in the script when it is passed as a QObject.
I am confused on why I must use QObject and let the script auto cast it and I cannot reference my class directly if it is already registered. Also not sure if casting my class internally will have a performance hit or is just bad form?
Short Question: Why cant I reference a return object using my specific class identifier in a script?
I attached a very small code example that will show specifically what the problem is.
Bookmarks