hello frenz, i am having a small problem i am not able to figure out how to remove first 6 bytes from a QByteArray and append the next 40 bytes into another byte array or string.
something like i have to remove the first 6 bytes 03b702200001 and then append the next 40 bytes 00de00de00de00de00de00de00de00de00de00de00de00de00 de00de00de00de00de00de00de00de. after every 40 bytes i get a frame id which is 6 bytes length,i have to remove the frame id after every 40 bytes to get only the data i want..
This is what i tried to remove the first 6 bytes and append the next 40
for(int i=6; i< datstr.size(); i++)
{
newdat.append(datstr.at(i));
bytecount++
if(bytecount==40)
{
newdat.remove(0,6);
bytecount=0;
}
}
textBrowser->append(newdat);
datstr.clear();
Can some one pls help me out with a logic to do this. ?? i am stuck here
i am using QT C++ compiler to build the GUI application.
Reply With Quote
I don't follow your logic in the code above. You are starting at index 6 and appending 40 bytes, but then removing bytes 0-6 from your newdat array. You already skipped the first frame id with i=6, so why are you removing the first 6 bytes of your data? Why would you copy data just to remove it anyway? It should be pretty simple to code it just using the at() function you have above. I don't know what other functions you have available for a QDataArray. I am not going to write it out for you.
yea i am able to think about how to do this for the second iteration. .. this is the first time i am doing some thing like this. .. can you just give me a hint on how i sud go about doing it. . ?
thank you
hello frenz i solved my problem. This is what i did. :)
for(int i=0; i< datstr.size(); i++)
{
// newdat = datstr.mid(posi, 40); // y == "pine"
newdat.append(datstr.mid(posi, 80));
posi+=92;
//datposi+=40;