ruben.rodrigues
15th August 2011, 11:33
Hi!
I need to pack and unpack a QSqlQuery or a QSqlResult into a QByteArray and using a QDataStream. I need this because later I am supposed to send/received the QByteArray through a tcp socket.
To pack the QSqlQuery I used the result() function:
QByteArray dataBlock;
QDataStream dataStream(&dataBlock, QIODevice::WriteOnly);
dataStream << sqlQuery.result();
return dataBlock;
now when I try to do the opposite I get errors, QDataStream::operator :
QSqlResult *result;
QDataStream dataStream(&qba, QIODevice::ReadOnly);
dataStream >> result; //error
_query = QSqlQuery(result);
is there a solution or even a better way to do this?
thanks
I need to pack and unpack a QSqlQuery or a QSqlResult into a QByteArray and using a QDataStream. I need this because later I am supposed to send/received the QByteArray through a tcp socket.
To pack the QSqlQuery I used the result() function:
QByteArray dataBlock;
QDataStream dataStream(&dataBlock, QIODevice::WriteOnly);
dataStream << sqlQuery.result();
return dataBlock;
now when I try to do the opposite I get errors, QDataStream::operator :
QSqlResult *result;
QDataStream dataStream(&qba, QIODevice::ReadOnly);
dataStream >> result; //error
_query = QSqlQuery(result);
is there a solution or even a better way to do this?
thanks