I have a requirement where I have to ready a binary file and search for a particular address given by user and store the hex value of corresponding address in an array.
I have a file like "39059921.HA". Which i have to read on a button click.
I have opened the file in hex viewer and the inside content are like below
Block 0 Strarts at:0x 0 Ends at: 0x4319 (Length:0x431A=17178)
00000000: 03 01 00 02 04 00 55 50 41 00 00 00 00 00 00 00 ......UPA.....
00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................
00000020: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF .................
00000030: 66 65 74 79 00 00 00 00 00 00 00 00 CD 38 1A D1 .fety........
-------
-------
I tried reading the file like normal text file but i am getting some junk value.
Qt Code:
  1. QFile file("39059921.HA");
  2.  
  3. if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
  4. {
  5. return;
  6. }
  7. QTextStream stream(&file);
  8. while(!stream.atEnd())
  9. {
  10. QString line = stream.readLine();
  11. qDebug()<<"data"<<line;
  12. }
  13.  
  14. file.close();
  15.  
  16. output:-I get the output like below
  17. data""—¶GÐEÐk|‘s‰žÃ*¥òm[ˆ8êܳ$7¢,HYNܾlFTÛ/õêÃâlÂ¥Bóîä1©»0*¢Ïƒ©è~Êßl«Ê2<ˆWXˆ³8{Èà IÃ…@"
  18. data"&ÓûcVp„êp1¡Çø–ڐñ T77”(/•´„ŸÎµ°©¯”9·|ÞmJ"5²ŒBÂ¡ó” ˜NWeB(¯e£÷•ˆ^Ó$Òo›ùt{€"“Ts²–)‡hexText "ppÀhexText "pqÆ pˆà p•ÂÐx‡õphà "
To copy to clipboard, switch view to plain text mode 
How can I read the above and search for a particular address