Results 1 to 9 of 9

Thread: Obtain const QImage from QByteArray

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Obtain const QImage from QByteArray

    What you probably want is:
    from server:
    Qt Code:
    1. QDataStream stream(&arr, QIODevice::WriteOnly);
    2. stream.setVersion(QDataStream::Qt_4_7);
    3.  
    4. QImage image = ...;
    5. stream << image;
    To copy to clipboard, switch view to plain text mode 
    then in client:
    Qt Code:
    1. QDataStream stream(&some_socket, QIODevice::ReadOnly);
    2. stream.setVersion(QDataStream::Qt_4_7);
    3.  
    4. QImage image = ...;
    5. stream >> image;
    To copy to clipboard, switch view to plain text mode 
    The operators are in the documentation, >> and << for QImageHope this helps

  2. The following user says thank you to Fallen_ for this useful post:

    gorsanmo (26th April 2011)

  3. #2
    Join Date
    Apr 2011
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Obtain const QImage from QByteArray

    1.
    QDataStream stream(&some_socket, QIODevice::ReadOnly);
    2.
    stream.setVersion(QDataStream::Qt_4_7);
    3.

    4.
    QImage image = ...;
    5.
    stream >> image;


    What would be the code for QImage ( QIMage= ... )
    Thanks
    GOrka

  4. #3
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Obtain const QImage from QByteArray

    from the client should just be "QImage image;"

  5. The following user says thank you to Fallen_ for this useful post:

    gorsanmo (26th April 2011)

  6. #4
    Join Date
    Apr 2011
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Obtain const QImage from QByteArray

    when you use
    QDataStream stream(&some_socket, QIODevice::ReadOnly);
    stream.setVersion(QDataStream::Qt_4_7);

    QImage image = ...;
    stream >> image;
    Does it mean that all the stream is kept in the stream ?

    What does QImage image = ... mean ? DOes it mean that QImage image = new QImage ()?

  7. #5
    Join Date
    Apr 2011
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Obtain const QImage from QByteArray

    Hello :
    Do you need to use in your TCP Client any kind of SIGNAL -- SLOT ?
    For example , the one that I use here :

    QTCPSocket socket = new QTCPSocket(this);
    soket ->connectToHost("XXX","YYY");
    connect(soket,SIGNAL(readyRead()),this,SLOT(leer_c aracter()))

    Could you answer me as soon as possible ?
    Thanks
    gorsanmo


    Added after 42 minutes:


    As you have said , the code of the client is the following :


    then in client:
    QDataStream stream(&some_socket, QIODevice::ReadOnly);
    stream.setVersion(QDataStream::Qt_4_7);

    QImage image = ...;
    stream >> image;
    The operators are in the documentation, >> and << for QImageHope this helps

    1) Is it supponed that in QDataStream(&some_socket, QIODevice::ReadOnly) , &some_socket is a QByteArray obtained reading an especific socket ?
    For example

    soket = new QTcpSocket(this);
    soket->connectToHost("xxx","yyy");

    connect(soket,SIGNAL(readyRead()),this,SLOT(leerca racter()));





    leercaracter()
    {
    some_socket = soket->readall()
    QDataStream(&some_socket, QIODevice::ReadOnly)
    }
    Last edited by gorsanmo; 27th April 2011 at 00:47.

Similar Threads

  1. Replies: 3
    Last Post: 18th November 2010, 17:52
  2. const char* QImage Format?
    By grabalon in forum Newbie
    Replies: 2
    Last Post: 13th May 2010, 00:44
  3. Streaming QImage (QByteArray, QDataStream, QBuffer)
    By knarz in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2009, 22:05
  4. Constructing QImage from QBytearray
    By dbrmik in forum Newbie
    Replies: 6
    Last Post: 16th December 2008, 15:00
  5. QImage to QByteArray
    By navi1084 in forum Qt Programming
    Replies: 5
    Last Post: 15th October 2008, 09:36

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
  •  
Qt is a trademark of The Qt Company.