Results 1 to 2 of 2

Thread: How to obtain a QI,age from QTcpSocket->readAll

  1. #1
    Join Date
    Apr 2010
    Posts
    13
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default How to obtain a QI,age from QTcpSocket->readAll

    Hello , I am implementing a QTCP Client for receiving images . I have the following code :

    Qt Code:
    1. void NetworkControl::aceptar_conexiones()
    2. {
    3.  
    4. QTcpSocket *soket = new QTcpSocket(this);
    5. const QString direc ="xxxxxxxxxx";
    6. quint16 port = 4445;
    7. soket->connectToHOst(direc,port)
    8. connect(soket,SIGNAL(readyRead()),this,SLOT(leercaracter()))
    9.  
    10. }
    11.  
    12. void NetworkControl::leerCaracter()
    13. {
    14.  
    15. QTcpSocket *socket (QTcpSocket *)sender();
    16. QBYteArray *b1 = socket->readAll();
    17.  
    18. QImage ax= new QImage("xxxxxxxx");
    19.  
    20. ax->Load(b1);
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

    I would like to obtain a QImage from the QByteArray obtained by socket->readAll(). What would be the best way for obtaining it ?
    I use the following code :

    Qt Code:
    1. QTcpSocket *socket (QTcpSocket *)sender();
    2. QBYteArray *b1 = socket->readAll();
    3.  
    4. QImage ax= new QImage("/home/aux/real.jpg");
    5.  
    6. ax->Load(b1);
    To copy to clipboard, switch view to plain text mode 


    Any suggestion ?
    Thanks.
    Gorka

    I use the following

    Hello , I am trying to obtain a const QIMage from a QByteArray. Does any body know how to obtain it ?
    Thanks
    Gorka

    Hello
    I am trying to transmit and represent video streaming from a video WebCam.
    The receiver is based on a QTCPSocket , which obtains all the images the following way :

    void NetworkControl::leercaracter()
    {

    QTcpSocket *socket = ( QTcpSocket * )sender()
    QByteArray nbytes2 = socket->readAll();

    }


    I would like to obtain a const QImage from nbytes_2. What is the best way ?

    I use the following way but it does not work :


    const QImage *im1 = new QImage("xxxxxxxxx");


    im1 ->loadfromData(nbytes2);

    This code does not compile . Can you propose me any other code ? I need it for creating a MythImage anf MythUIIMage.
    Thanks
    Gorka
    Last edited by high_flyer; 27th April 2011 at 08:49. Reason: multi posting

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to obtain a QI,age from QTcpSocket->readAll

    Please don't multipost.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. is it possible to obtain the svg data from QgraphicsSvgItem?
    By sanjayshelke in forum Qt Programming
    Replies: 7
    Last Post: 22nd February 2011, 14:50
  2. Question on QByteArray::QHttp::readAll()
    By ask8y@yahoo.com in forum Qt Programming
    Replies: 2
    Last Post: 17th June 2010, 15:51
  3. loss of data recieved using http->readAll()
    By arunredi in forum Qt Programming
    Replies: 5
    Last Post: 26th June 2008, 17:12
  4. QT-wince and QHttp::readAll() trouble....
    By AcerExtensa in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 12th June 2008, 09:40
  5. QHTTP Readall() function
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 17th April 2007, 00:55

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.