[Qt-interest] Transferring a QPixmap through QTcpSocket

sarvesh saran aquarian.thunder at gmail.com
Thu Apr 7 14:12:52 CEST 2011


> On Thu, Apr 7, 2011 at 4:30 PM, Joshua W Joseph <
> joshua at blueprint-group.co.ke> wrote:
>
>>  Hi All,
>>
>> I have two simple applications which are network based. The 'server' takes
>> a screenshot of its computer. When a 'client' connects, it will receive the
>> captured image. These are basically the fortune server/client examples
>> modified to transmit images instead of text.
>>
>>
>>
>> The client receives some data, but how to I:
>>
>>     1. Ensure that all of the sent data is received, and
>>
>
>        your code is ensuring this already.
>
>
>
>>     2. Convert the received data into a QPixmap so that it can be
>> displayed.
>>
>
> the operator>> takes care of that (
> http://doc.qt.nokia.com/latest/qpixmap.html#operator-lt-lt-101).....itsall there in your code!
>
>
>
On closer inspection of your code, it looks like you are writing :
out << (quint16)(block.size<http://doc.qt.nokia.com/latest/qbytearray.html#size>()
- sizeof(quint16));

i.e size of your buffer as an quint16

yet while reading you're using quint64 :

if (tcpSocket->bytesAvailable() < (int)sizeof(quint64))
    return;
in >> blockSize;

thanks,
Sarvesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110407/34eaf855/attachment.html 


More information about the Qt-interest-old mailing list