void Mythread::run()
{
std::cout << " thread run ....." << std::endl;
char *buf=(char *)malloc(512);
int r_bytes;
if(buf==NULL)
{
perror("malloc:");
exit(1);
}
std::cout << " malloc success ....." << std::endl;
while(1)
{
r_bytes=read(fd,buf,sizeof(buf));
buf[r_bytes]='\0';
QString txt=ADtext->toPlainText()+QString::fromLocal8Bit(buf,r_bytes);
ADtext->setText(txt);
ADtext->update();
}
}
这一段是我重新实现的run方法,但是一执行窗体就自动消失了?请问为什么?循环读取串口来的数据在TextEdit (ADtex)t中显示。