hi all,

i'm newbie in qt, and i have to make a program in qt to read data from usb device, digital compass to be more precisely

and this is the part of my code

in .h file
Qt Code:
  1. private:
  2. char buf[256];
  3. QString line
To copy to clipboard, switch view to plain text mode 

in .cpp
Qt Code:
  1. while(running) {
  2. res = read(fd, buf, 255);
  3. if(res > 1) {
  4. buf[res-1] = 0;
  5. line = buf;
  6. emit newData(line);
  7. }
  8. }
To copy to clipboard, switch view to plain text mode 

but when i try to run it i got message : "The program has unexpectedly finished"
when i try to comment the "emit newData(line)" with "qDebug() << line;" it'll show the data that i want.
even when i try to use mid() function on line like this "line.mid(2,5)" it'll show the same message, but not with "line.length()"

my purpose it to emit the data, and parse in other class outside this file

anybody can help me please

thanks in advance

cheers,