I'd probably use 'map', but you could use 'read', since your reading the file.
I'd probably use 'map', but you could use 'read', since your reading the file.
So, what command i must use? Can anyone writean example?
QFile::read(), as already said.
Read the docs for QFile.Can anyone writean example?
Small print: Actually we do know what you are asking for and we're just playing stupid until you are sure if you really want us to write a parser for your file structure (you don't want us to do it, I assure you).
Ok, can you tel me, how for example read firs section of file and convert in to QString?![]()
I think I'd prefer to use a QByteArray rather than a QString, considering the binary nature of the file, and you can see from the documentation how to read into a QByteArray.
You can then even convert the tags, such as 'ANPK' to quint32 and compare them that way instread, which is properly what the original designer intended, or cast to an appropriate struct.
Qt Code:
void MainWindow::on_action_IFP_triggered() { // QFile::map() qDebug() << line; } }To copy to clipboard, switch view to plain text mode
I recived "ANPKin"
I do this right?
You do realise what readLine does, right?
The hint is in the name.
As i anderstand it reads fil line and goes no next, right? In this case why next line shows "NA" when in hex we have
00000000:41 4e 50 4b ec f1 15 00 49 4e 46 4f 0b 00 00 00 ANPKмÑ..INFO....
00000010:02 00 00 00 63 6e 74 5f 31 61 00 dc 4e 41 4d 45 ....cnt_1a.ЬNAME
00000020:08 00 00 00 43 53 70 68 69 6c 00 44 47 41 4e ....CSphil.DGAN
Qt Code:
// process_line(line); qDebug() << line << line1; qDebug() << line1; qDebug() << line2; qDebug() << line3; qDebug() << line4; qDebug() << line4;To copy to clipboard, switch view to plain text mode
I recive :
"ANPKin
"NA"
"A???f?¶eI?o®NADjuA?u?????°?x=lK????f ?I??·NAKruAAµ??"""?^a~=»?¤?5??¬TI? EANAzuA`I??«?*???=A????_?°uH?WCNA??uA˜ ?C?333?? ?=µ?????? H?CNA?uA?&E??»;?*9~=3U??cq??8H?"ANA\?uA
"?AUuA?E??DDA??O?=?'??3$?+µB?#oIAjOuAXe????E ?µ??=©0???[$?¤?B?uOIAoOuA`??III?*7?=?O??rE$?=B??IAIuA ??N?C??=?c˜?qs%?)?A?p?IA§EuA U??UUO???=?u??u-&??'A?r|IAA?uA?G????U?e~=Ak???¬&?u?@?Y`IA??uAi???YY?Zx=
???E2'?]h@?ACIAg±uAaL??""a?0q=(???e'??a??m*IAI¤uA? 8??ff??¤ j=?Q??Pz(?Ev??:IA??uA`??«?e??ve=o%??e*(?WX??. uIA¦?uAoE??iii?oeb=}????(?R??}aIA?uA?'??33o? ?d=n????(??<???IIAa?uAP°??ww??µRk='R???A(? )7??Z»IA??uAF»??»u?v?n=/4??`A(?o,??y©IAE©uA0?»?
"@®._=?1|??)????nIAo?uA0?»?II@A?]=?{?/?(?oB??
bIAGCuApe??ii@? a=LA?©?(?A~???[IA?OuA »?@?¶c=z???eb(?????VIA1UuAAC»?33@AAa =??Au'?(y??vKIANYuAe??UU@?o^=???W?'??h@?CIA??uAa}??ww@??]=j?L'?;?@?UBIA;auA(?????@Xg\=M?}?WQ'?E?@?IIIA} auAo>???»@µ9[=iH|?iZ'?±?@?
OIA0auA?»???Y@*Z=Y{?4O'??¤@? TIA#auAE???
"@®._=?1|??)????nIAo?uA0?»?II@A?]=?{?/?(?oB??
bIAGCuApe??ii@? a=LA?©?(?A~???[IA?OuA »?@?¶c=z???eb(?????VIA1UuAAC»?33@AAa =??Au'?(y??vKIANYuAe??UU@?o^=???W?'??h@?CIA??uAa}??ww@??]=j?L'?;?@?UBIA;auA(?????@Xg\=M?}?WQ'?E?@?IIIA} auAo>???»@µ9[=iH|?iZ'?±?@?
OIA0auA?»???Y@*Z=Y{?4O'??¤@? TIA#auAE???
Hint: binary files have no "lines", so readLine() will stop reading at a random place (or exactly when it enounters a \n character).
I suggest you take a piece of paper and write down a concept of how you intend to process the file step by step (the specification in the first post is all help you need). Only then sit down in front of your computer and start implementing it.
Like I got told on the first day of my employment induction "Projects are typically 80% documentation and research, and 20% coding." and it's true. There's no point randomly coding stuff and hoping it'll work. Figure it all out first then code it.
Bookmarks