Results 1 to 4 of 4

Thread: send custom object with qbytearray

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default send custom object with qbytearray

    Hello everybody,

    I would like to transfer a custom object with qbytearray. I tried to send "TetrixShape board[BoardWidth * BoardHeight];" This is a custom object.
    I would think that if you append this to qbytearray that this object will be converted to a bytearray. But this doesn't happen. I get the following error: invalid conversion from 'TetrixShape*' to 'char' and

    Can somebody help me?

    Thanks

    Qt Code:
    1. TetrixShape board[BoardWidth * BoardHeight];
    2.  
    3.  
    4. ...
    5.  
    6.  
    7. data.append(board);
    8. emit send_board(board);
    9.  
    10. ...
    11.  
    12.  
    13. void server::send_data(QByteArray data)
    14. {
    15. QDataStream out(&data, QIODevice::WriteOnly);
    16. out << (quint16)0;
    17. out << data;
    18. out.device()->seek(0);
    19. out << (quint16)(data.size() - sizeof(quint16));
    20. connection->write(data);
    21. qDebug()<<data;
    22. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by kevindebb; 8th May 2012 at 17:03.

Similar Threads

  1. Replies: 0
    Last Post: 26th April 2011, 11:02
  2. Replies: 2
    Last Post: 5th October 2010, 07:07
  3. Can you add a custom object to a SQL database?
    By agerlach in forum Qt Programming
    Replies: 4
    Last Post: 30th June 2010, 15:51
  4. Convert QByteArray to object and vice versa
    By DiamonDogX in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2009, 20:07
  5. Replies: 3
    Last Post: 14th October 2008, 21:04

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.