Results 1 to 14 of 14

Thread: How to read the Binary data from QFile to buffer of type BYTE*???

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to read the Binary data from QFile to buffer of type BYTE*???

    How to read the Binary data from QFile to buffer of type BYTE*???

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to read the Binary data from QFile to buffer of type BYTE*???

    I assume that BYTE is some typedef or macro that is equivalent to char.

    QByteArray and QIODevice::readAll(). You can access the bytes through QByteArray::data().

  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to read the Binary data from QFile to buffer of type BYTE*???

    How to convert QByteArrray to BYTE*???

  4. #4
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to convert QByteArrray to BYTE*???

    How to convert QByteArrray to BYTE*???

  5. #5
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to convert QByteArrray to BYTE*???

    For me it looks like you expect that we're gonna solve all your issues for you - a while ago you've posted the same question here: link to thread
    Please, can you kindly tell us what have you tried so far ? Because it looks like you are saying "I don't want help, I want a solution".


    ===
    Note: I merged the threads, so this message was originally a response to the post while it was at a different place! (Lykurg)
    Last edited by Lykurg; 9th March 2011 at 10:11.

  6. #6
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to convert QByteArrray to BYTE*???

    While reading the same file for the second time.. It returns null in the buffer..
    I am using the following code::

    QByteArray buf;
    buf=file.readAll();

    The above code is inside the while loop. If it enters for the second time.. buf value becomes null. Pls help me...

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to convert QByteArrray to BYTE*???

    So what you are trying to do is read the entire contents of the file more than once?

  8. #8
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to convert QByteArrray to BYTE*???

    Yes.. That is the case

  9. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to convert QByteArrray to BYTE*???

    Well, then it is nonsense. Simply do something like:
    Qt Code:
    1. buf += buf;
    To copy to clipboard, switch view to plain text mode 
    . If you still want to read the file again, use QIODevice::reset().

  10. #10
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to pass char * data to Byte* in QT??

    How to pass char * data to Byte* in QT??

  11. #11
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to read the full contents of the File 'n' times in QT??

    How to read the full contents of the File 'n' times in QT??


    Added after 19 minutes:


    I am getting the values till the last loop runs. After that nothing is present in the buffer.

    Am using the following code:
    int pos1=file.pos();
    buf=file.read(size);
    int pos2=file.pos();
    strcpy(buffer,buf.data());

    PLS HELP ME..
    Last edited by Gokulnathvc; 10th March 2011 at 07:14.

  12. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to read the full contents of the File 'n' times in QT??

    Stop asking the same question over and over - it rapidly annoys people who might be inclined to help.

    You already have the answer to this in
    http://www.qtcentre.org/threads/3947...TE*?highlight=

  13. #13
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to pass char * data to Byte* in QT??

    As I mentioned earlier, a Byte (or is that BYTE) is usually typedef or macro for a "char" on every platform I have handy. So a BYTE* or Byte* is a char*. Equating these two has nothing to do with Qt, it is straight C++.
    Last edited by ChrisW67; 10th March 2011 at 07:32.

  14. #14
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to pass char * data to Byte* in QT??

    So, the order of responses gets a little messy here because I merged the thread. But we really do not need 4 (in letters: four) threads on that topic.

Similar Threads

  1. Read a Byte from Binary File
    By umulingu in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2010, 06:20
  2. QFile - file read parts of the buffer
    By eugen_Qt in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 14:52
  3. QFile, QDataStream reading binary data
    By yren in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2009, 06:34
  4. can`t read a binary data!
    By blm in forum Qt Programming
    Replies: 8
    Last Post: 18th September 2008, 16:56
  5. How can I read binary data to QString?
    By zolookas in forum Newbie
    Replies: 2
    Last Post: 29th July 2008, 20:03

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.