D
D
Denis2016-10-12 00:07:40
Qt
Denis, 2016-10-12 00:07:40

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

1 answer(s)
P
Philipp, 2016-10-12
@D3Nd3R

Look here www.qtcentre.org/threads/35760-how-to-use-qtcpsock...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question