16,818
社区成员




void QTcpSocketThread::sendQueryValueCmd()//10 tongyong
{
if(qureyReady)
{
QSensor* sensor = sensorsVector.at( currentQueryIndx );
sensor->queryValueCmd(cmdBuffer);
tcpSocket->write( cmdBuffer );
qDebug()<<"sendQuerycmd10:"<<cmdBuffer.toHex()<<endl;
}
/**timer=new QTimer();
timer->setInterval(1000*3);
timer->moveToThread(this);
connect(timer,SIGNAL(timeout()),this,SLOT(sendQueryNextSensorValueCmd()),Qt::DirectConnection);
timer->start();**/ 已经证实这么写是错误的,行不通
//我想在此emit一个信号,connect某个函数,激活计时器,开始计时,之后的我会写,这个connect写在哪?又怎么关联起来
}
connect( tcpSocket,
SIGNAL( readyRead() ),
this,
SLOT( socketRead() ),
Qt::DirectConnection );
然后再socketRead()中recvPkgBuffer = tcpSocket->readAll();
,然后解析数据,然后currentQueryIndx加1,currentQueryIndx是存在vector中