11-28-2012 08:21 AM
11-28-2012 09:46 AM
It's worth trying to pass the type by reference (just change the signal's signature and dereference with a leading * when passing in) since your type registration looks correct to me.
If the above doesn't work I can think of two other approaches:
2) Structure your C++ class so that it is a proper plugin to the QML environment - create a QML object and call your network services via Q_INVOKABLE methods. Use signals to tell the QML object when the parsing is complete and its properties contain valid values.
Hope that helps.
11-28-2012 11:17 AM
11-28-2012 11:44 AM
Are you passing the QObject pointers to the declarative engine via setContextProperty()? That's not the same thing at all as passing the pointer in a signal since it's explicitly telling the engine to set up the QML bindings to the properties. Changing the method signature for the signal to QObject * rather than the custom class is definitely worth a try as well though, since the problem appears to be that QML is not recognising the type of object it's getting and has simply wrapped the pointer type with a QVariant.
11-29-2012 04:10 AM
11-29-2012 04:42 AM
Great. You'd expect the Q_INOKABLE not to work if you pass it as a QObject* because those methods belong to the subclass you registered and the declarative engine does not know that it is actually one of those. The QObject base class provides generic access to properties though.
You should be able to pass a type you've registered in and have it recognised correctly somehow but if you've got what you need for now then that's the important thing!
Actually for anyone coming to this thread later, what I said before about automatically generated copy constructors is misleading in this context. It's true but the QObject base class and all Qt framework subclasses actually declare private ones, so you can't assign objects rather than pointers or references to them. They recommend you do the same in your own classes:
I'm just coming back to Qt after almost 2 years and dusting off the rust on my knowledge.
11-29-2012 11:07 AM
11-29-2012 11:19 AM
I don't use forward declaration as far as i can see, i include the header of the class.
12-03-2012 05:57 AM
12-03-2012 06:34 AM
>> The first use works, but as soon as i try the second usecase i get a segfault.
By this do you mean a second attempt to access the thing passed in the signal by QObject pointer causes a segfault? Or something else?
If the former, I assume you have an issue with the ownership of the object and its lifetime. Sharing pointers between the languages can get messy. Useful docs here: