27 lines
454 B
C++
27 lines
454 B
C++
|
#include "thread.h"
|
||
|
|
||
|
Thread::Thread(QTcpSocket *s)
|
||
|
{
|
||
|
isStop = false;
|
||
|
socket = s;
|
||
|
}
|
||
|
|
||
|
void Thread::myTimeout(){
|
||
|
while (!isStop){
|
||
|
connect(socket, &QTcpSocket::readyRead, this, &Thread::clientInfoSlots);
|
||
|
if (isStop){
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Thread::clientInfoSlots(){
|
||
|
QByteArray ba = socket->readAll();
|
||
|
// 发送信号
|
||
|
emit sendToWidget(ba);
|
||
|
}
|
||
|
|
||
|
void Thread::setFlag(bool flag){
|
||
|
isStop = flag;
|
||
|
}
|