QObject subclass with properties used as a property in another QObject subclass?
-
Here is what I'm trying to do:
@
class Thing1 : QObject
{
Q_OBJECT
QPROPERTY(quint16 someStuff READ getsomeStuff WRITE setsomeStuff)public:
//all the junk you need
//including constructor, copy constr, destructor};
class Thing2 : public QObject
{
Q_OBJECT
QPROPERTY(Thing1 aThing READ getaThing WRITE setaThing)
//other propertiespublic:
//all the junk you need.
};Q_DECLARE_METATYPE(Thing1)
@The problem is this: when you implement the setaThing function, you get a compile error because the QObject::operator= is private. So is what I am trying to do completely impossible? I can't have a class with properties as a property for another class with properties?
-
Yes, it is impossible. QObject cannot be copied, and properties need to be able to be copied. The only thing you could do is to use a pointer to your Thing1 as the property in Thing2.
-
why object of QObject or its subclass can't be copy can be found here:
http://qt-project.org/doc/qt-4.8/object.html#identity-vs-value