QxSerializeQDataStream_QSharedPointer
Posted: Tue Jul 24, 2018 8:01 pm
The following code fails to compile when QxSerialization is turned off. Qt Serialization takes over and does not understand abstract types. I'm not sure how to turn Qt Serialization off too. It looks like it's too closely baked into the framework and needed for ancillary operations.
- Code: Select all
template <typename T>
QDataStream & operator<< (QDataStream & stream, const QSharedPointer<T> & t)
{
{
qint8 iIsNull = 0;
stream >> iIsNull;
if (! iIsNull) { t = QSharedPointer<T>(new T()); stream >> (* t); }
else { t = QSharedPointer<T>(); }
return stream;
}