You got an answer on StackOverflow already, but to repeat: he’s right, a QObject is always passed from C++ to QML by pointer, and a Q_GADGET is always passed by value. That means Q_GADGET is only suitable for smallish self-contained classes, because it will always be copied.
> On 13 Apr 2017, at 20:31, Russell, Matthew <[email protected]> wrote: > > Why can my Q_GADGET be read perfectly in QML (JS) but not my Q_OBJECT? > > I created a class, registered it (Q_DECLARE_METATYPE), and then push > instances of it into a QVariantMap. If the object is a Q_GADGET my JS can > read it perfectly, but when I switch it to a Q_OBJECT, the objects are blank. > > I placed some code examples on SO here: > http://stackoverflow.com/questions/43398740/qml-can-see-my-q-gadget-but-not-q-object > > Basically I’ve narrowed it down to Q_GADGET vs Q_OBJECT, nothing else seems > to make any difference. I’d prefer to use Q_OBJECT so that I can use signals > and other objects in the QML/JS can bind to them. > > Thanks. > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
