Results 1 to 14 of 14

Thread: QDataStream and QByteArray issue

Hybrid View

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

    Default Re: QDataStream and QByteArray issue

    QByteArray data = QByteArray::fromHex("200000008305370FFFFFF63050000 8E");
    QDataStream dataStreamToReadFrom(&data, QIODevice::ReadOnly);
    QByteArray convertedData;
    dataStreamToReadFrom >> convertedData;

    QString Str = data.toHex();
    QString convertedStr = convertedData.toHex();

    Here Str and convertedStr are not same. Why?

    I want to both QByteArray data and converted Data to be the same. How to achieve that.?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: QDataStream and QByteArray issue

    Do not double post. Make one post, in one section of the forum only, and it will be read.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Apr 2021
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QDataStream and QByteArray issue

    CAN SOMEONE HELP ME!!? im using linux ubuntu
    Im getting this error
    fatal error: QTextStream: No such file or directory

    Qt Code:
    1. #include "QTextStream"
    2. #include <QDebug>
    3. QTextStream cin(stdin);
    4. QTextStream cout(stdout);
    5. QTextStream cerr(stderr);
    6. int main() {
    7. int num1(1234), num2(2345) ;
    8. cout << oct << num2 << '\t'
    9. << hex << num2 << '\t'
    10. << dec << num2
    11. << endl;
    12. double dub(1357);
    13. cout << dub << '\t'
    14. << forcesign << dub << '\t'
    15. << forcepoint << dub
    16. << endl;
    17. dub = 1234.5678;
    18. cout << dub << '\t'
    19. << fixed << dub << '\t'
    20. << scientific << dub << '\n'
    21. << noforcesign << dub
    22. << endl;
    23. qDebug() << "Here is a debug message with " << dub << "in it." ;
    24. qDebug("Here is one with the number %d in it.", num1 );
    25. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by d_stranz; 2nd April 2021 at 16:40. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: QDataStream and QByteArray issue

    Use <QTextStream> not "QTextStream". #include with quotes only looks in the local directory.

    Please do not hijack a thread to make an unrelated post. Start a new thread.
    Last edited by d_stranz; 2nd April 2021 at 16:50.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Streaming QImage (QByteArray, QDataStream, QBuffer)
    By knarz in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2009, 22:05
  2. QByteArray problem
    By Misenko in forum Qt Programming
    Replies: 17
    Last Post: 4th October 2008, 21:53
  3. Reading QByteArray from QDataStream Qt3.3
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 20:23

Tags for this Thread

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.