fg_psycho
5th May 2009, 17:58
Hi,
I try to serialize the member variable QMap <int, QByteArray> in an overloaded operator function, but I get the following compiler errror: no match for 'operator<<' in 'ds << map'
This is my overloaded operator function
QDataStream& operator<<(QDataStream& ds, const NetShmMessage & msg )
{
QMap<int, QByteArray> map;
map[1] = QByteArray("one");
map[2] = QByteArray("two");
ds << map;
return ds;
}
In my main I'm calling
QBuffer tempDevice;
tempDevice.open(QIODevice::WriteOnly);
QDataStream stream(&tempDevice);
stream << msgNet;
msgNet is an instance of NetShmMessage wich is holding the map.
If I'm calling stream << map (with previos data definitions) in the main it is working, but not from the overloaded operator. What am I missing?
The overloaded operator is defined as global with friend prefix.
Any help would be really appreciated.
I try to serialize the member variable QMap <int, QByteArray> in an overloaded operator function, but I get the following compiler errror: no match for 'operator<<' in 'ds << map'
This is my overloaded operator function
QDataStream& operator<<(QDataStream& ds, const NetShmMessage & msg )
{
QMap<int, QByteArray> map;
map[1] = QByteArray("one");
map[2] = QByteArray("two");
ds << map;
return ds;
}
In my main I'm calling
QBuffer tempDevice;
tempDevice.open(QIODevice::WriteOnly);
QDataStream stream(&tempDevice);
stream << msgNet;
msgNet is an instance of NetShmMessage wich is holding the map.
If I'm calling stream << map (with previos data definitions) in the main it is working, but not from the overloaded operator. What am I missing?
The overloaded operator is defined as global with friend prefix.
Any help would be really appreciated.