kevindebb
8th May 2012, 16:28
Hello everybody,
I would like to transfer a custom object with qbytearray. I tried to send "TetrixShape board[BoardWidth * BoardHeight];" This is a custom object.
I would think that if you append this to qbytearray that this object will be converted to a bytearray. But this doesn't happen. I get the following error: invalid conversion from 'TetrixShape*' to 'char' and
Can somebody help me?
Thanks
TetrixShape board[BoardWidth * BoardHeight];
...
QByteArray data;
data.append(board);
emit send_board(board);
...
void server::send_data(QByteArray data)
{
QDataStream out(&data, QIODevice::WriteOnly);
out << (quint16)0;
out << data;
out.device()->seek(0);
out << (quint16)(data.size() - sizeof(quint16));
connection->write(data);
qDebug()<<data;
}
I would like to transfer a custom object with qbytearray. I tried to send "TetrixShape board[BoardWidth * BoardHeight];" This is a custom object.
I would think that if you append this to qbytearray that this object will be converted to a bytearray. But this doesn't happen. I get the following error: invalid conversion from 'TetrixShape*' to 'char' and
Can somebody help me?
Thanks
TetrixShape board[BoardWidth * BoardHeight];
...
QByteArray data;
data.append(board);
emit send_board(board);
...
void server::send_data(QByteArray data)
{
QDataStream out(&data, QIODevice::WriteOnly);
out << (quint16)0;
out << data;
out.device()->seek(0);
out << (quint16)(data.size() - sizeof(quint16));
connection->write(data);
qDebug()<<data;
}