Results 1 to 3 of 3

Thread: inver data from QByteArray

  1. #1
    Join Date
    Sep 2008
    Posts
    84
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default inver data from QByteArray

    hii...
    I'm reading file & stroing it in QBYteArray.
    The question is :
    How can we invert data stored in QByteArray ?

    thanks in advanced

  2. #2
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: inver data from QByteArray

    If the copying is allowable, one of solution is as follows.

    Qt Code:
    1. QByteArray cstring("Qt is cross platform C++ application framework.");
    2. const int charCount = cstring.count();
    3. qDebug() << cstring;
    4.  
    5. QByteArray invertedCString;
    6. invertedCString.resize(charCount);
    7. for(int i = 0; i < cstring.count(); ++i) {
    8. invertedCString[i] = cstring.at(charCount - 1 - i);
    9. }
    10. qDebug() << invertedCString;
    To copy to clipboard, switch view to plain text mode 

    if your string is multi bytes string, you can use QString instead.
    kichi

  3. #3
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: inver data from QByteArray

    Qt Code:
    1. for(int i = 0; i < cstring.count(); ++i) {
    To copy to clipboard, switch view to plain text mode 

    I'm sorry, I modified the code.

    Qt Code:
    1. for(int i = 0; i < charCount; ++i) {
    To copy to clipboard, switch view to plain text mode 
    kichi

Similar Threads

  1. Regarding qbytearray
    By mohanakrishnan in forum Qt Programming
    Replies: 7
    Last Post: 19th November 2009, 13:38
  2. Replies: 9
    Last Post: 25th July 2009, 13:27
  3. QByteArray
    By gyre in forum Newbie
    Replies: 4
    Last Post: 9th October 2007, 18:30
  4. QByteArray in Qt3
    By joseph in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2007, 06:16
  5. QByteArray with network data
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 1st June 2007, 17:53

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.