Results 1 to 3 of 3

Thread: QDataStream and QSql Object. Urgent!! please

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    100
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default QDataStream and QSql Object. Urgent!! please

    Hi!

    I need to pack and unpack a QSqlQuery or a QSqlResult into a QByteArray and using a QDataStream. I need this because later I am supposed to send/received the QByteArray through a tcp socket.

    To pack the QSqlQuery I used the result() function:

    Qt Code:
    1. QByteArray dataBlock;
    2. QDataStream dataStream(&dataBlock, QIODevice::WriteOnly);
    3.  
    4. dataStream << sqlQuery.result();
    5.  
    6. return dataBlock;
    To copy to clipboard, switch view to plain text mode 

    now when I try to do the opposite I get errors, QDataStream:perator :

    Qt Code:
    1. QSqlResult *result;
    2. QDataStream dataStream(&qba, QIODevice::ReadOnly);
    3.  
    4. dataStream >> result; //error
    5.  
    6. _query = QSqlQuery(result);
    To copy to clipboard, switch view to plain text mode 

    is there a solution or even a better way to do this?

    thanks
    Last edited by ruben.rodrigues; 15th August 2011 at 12:42.

Similar Threads

  1. Using auto_increment in QSql
    By SykeS in forum Newbie
    Replies: 3
    Last Post: 21st May 2010, 07:13
  2. QSql Database
    By addu in forum Qt Programming
    Replies: 6
    Last Post: 20th July 2009, 13:37
  3. Replies: 8
    Last Post: 27th August 2007, 15:45
  4. QSql error
    By renjithmamman in forum Qt Programming
    Replies: 4
    Last Post: 20th December 2006, 10:28
  5. Cannot use QSql drivers
    By xgoan in forum Newbie
    Replies: 2
    Last Post: 25th August 2006, 15:45

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.