Answer the question
In order to leave comments, you need to log in
How to pass QImage through QTcpSocket block by block?
Hello!
I'm trying to organize data exchange between a Qt application and a pythone application.
Faced the following problem:
the read method from QBuffer does not write data to the array and returns -1, respectively.
void Client::sendQImage(QImage &img)
{
QByteArray byteArr((char*)img.bits(),img.byteCount());
QBuffer buffer(&byteArr);
buffer.open(QIODevice::WriteOnly);
img.save(&buffer,"PNG");
qint64 sendSize = buffer.size();
qint64 actualWrite {1};
bool tmp = byteArr.isNull();
tmp = buffer.atEnd();
//actualWrite = pmSock->write(byteArr,);//work
char block2send[1024];
while(actualWrite != -1)
{
sendSize = buffer.read(block2send,qint64(1024));
//sendSize = buffer.read(pmBlockToSend,mBlockSize);
//actualWrite = pmSock->write(pmBlockToSend,sendSize);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question