Results 1 to 2 of 2

Thread: Using QTcpSocket

  1. #1

    Default Using QTcpSocket

    How can I send image from server to client using QTcpSocket?
    ......

    connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendImage()));
    ......
    void Server::sendImage()
    {
    QTcpSocket* socket = static_cast<QTcpSocket*>(sender());
    socket = tcpServer->nextPendingConnection();
    QImage image("image.jpeg");

    QByteArray ba;
    QBuffer buffer(&ba);
    buffer.open(QIODevice::WriteOnly);
    image.save(&buffer, "jpeg");

    socket->write(ba);
    }



    I'am quite newbie with QT and QTcpSocket.
    Thank advance.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using QTcpSocket

    See the attachments in this thread(post #19): http://www.qtcentre.org/forum/f-qt-p...rver-8502.html.

    It is exactly the same problem. The file is sent in buffers, but you can modify how that is done.

    Regards

Similar Threads

  1. Tell QTcpSocket which interface to use
    By rianquinn in forum Qt Programming
    Replies: 7
    Last Post: 23rd December 2010, 17:28
  2. Strange QTcpSocket behavior (debugged with Ethereal)
    By mdecandia in forum Qt Programming
    Replies: 23
    Last Post: 28th May 2007, 20:44
  3. How do I use QTcpSocket properly ?
    By mnemonic_fx in forum Qt Programming
    Replies: 13
    Last Post: 29th March 2007, 20:33
  4. Problems with QThread and QTcpSocket
    By cookiem in forum Qt Programming
    Replies: 6
    Last Post: 2nd November 2006, 08:25
  5. QTcpSocket disconnection problem
    By erdi in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2006, 21:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.