hi guys:
my serial code works well,AND NOTwant to use QextSerialPort:
Qt Code:
  1. int main(void)
  2. {
  3. int fd,nread;
  4. struct termios Opt;
  5. char buff[512];
  6. /*以读写方式打开串口*/
  7. fd = open( "/dev/ttySAC2", O_RDWR|O_NONBLOCK);
  8. if(-1 == fd)
  9. {
  10. perror("提示错误!");/* 不能打开串口一*/
  11. return 1;
  12. }
  13. //获取属性
  14. tcgetattr(fd, &Opt);
  15. tcflush(fd, TCIOFLUSH);
  16. //设置为19200Bps
  17. cfsetispeed(&Opt,B115200);
  18. cfsetospeed(&Opt,B115200);
  19. //8位数据位
  20. Opt.c_cflag &= ~CSIZE;
  21. Opt.c_cflag |= CS8;
  22. //无校验
  23. Opt.c_cflag &= ~PARENB; /* Clear parity enable */
  24. Opt.c_iflag &= ~INPCK;
  25. //1停止位
  26. Opt.c_cflag &= ~CSTOPB;
  27. //
  28. Opt.c_cc[VTIME] = 150; /* 设置超时15 seconds*/
  29. Opt.c_cc[VMIN] = 0; /* Update the options and do it NOW */
  30.  
  31. //设置属性
  32. tcsetattr(fd,TCSANOW,&Opt);
  33. tcflush(fd, TCIOFLUSH);
  34.  
  35. //
  36. while(!quit)
  37. {
  38. while((nread = read(fd, buff, 512))>0)
  39. {
  40. buff[nread+1] = '\0';
  41. write(fd,buff,nread);
  42. }
  43. }
  44. printf("quit\n");
  45. close(fd);
  46. exit (0);
  47. }
To copy to clipboard, switch view to plain text mode 
now i want to place it into a class ,inherited from QThread.
however,when i invoke close(fd), it report error.because close() is QT's default function to close the dialog.
how can i solve this problem?