Well, I don't think this is the problem. Trying to be more clear:
When I use stream operator on an indipendent objectA (not as data member of objectB) I got a correct result, this should tell me that the stream operator in objecta.h/cpp is ok, right? objectB has its own stream operator, and has objectA as data member. Calling the stream operator of objectB gives the error in first post. If in objectB I comment out the Q_PROPERTY() line regarding objectA (so it is not saved during stream operation) then it works. Probably I'm doing a wrong assumption: I presume that calling operator<< of objectB triggers operator<< of objectA when this one must be saved; am I wrong? (I know, a bit intricate). A very limited example:
objecta.h
{
Q_OBJECT
Q_PROPERTY( QString name READ name WRITE setName
) ...
};
QDataStream& operator<<( QDataStream& dataStream, const ObjectA & objectA );
class ObjectA : public QObject
{
Q_OBJECT
Q_PROPERTY( QString name READ name WRITE setName )
...
};
QDataStream& operator<<( QDataStream& dataStream, const ObjectA & objectA );
To copy to clipboard, switch view to plain text mode
objectb.h
{
Q_OBJECT
Q_PROPERTY( ObjectA objectA READ objectA WRITE setObjectA )
Q_PROPERTY( QString path READ path WRITE setPath
) ...
};
QDataStream& operator<<( QDataStream& dataStream, const ObjectB & objectB );
class ObjectB : public QObject
{
Q_OBJECT
Q_PROPERTY( ObjectA objectA READ objectA WRITE setObjectA )
Q_PROPERTY( QString path READ path WRITE setPath )
...
};
QDataStream& operator<<( QDataStream& dataStream, const ObjectB & objectB );
To copy to clipboard, switch view to plain text mode
main.cpp
ObjectA objectA;
out << objectA; // works
ObjectB objectB;
objectB.setObjectA(objectA)
out << objectB; // NOT works: QVariant::save: unable to save type 322.
ObjectA objectA;
out << objectA; // works
ObjectB objectB;
objectB.setObjectA(objectA)
out << objectB; // NOT works: QVariant::save: unable to save type 322.
To copy to clipboard, switch view to plain text mode
Bookmarks