PDA

View Full Version : i want use tcpsocket send a uchar data,, but there is no function conversion uchar to



tsuibin
5th November 2010, 17:05
i want use tcpsocket send a uchar data,, but there is no function conversion uchar to QByteArray

how can i use qtcpsocket send const unsigned char* src data ?

conversion to
QByteArray ?
QChar ?


this->m_tcpSocket = new QTcpSocket(this);
this->tcpSocket->connectToHost("192.168.0.111",8888);
connect(this->tcpSocket,SIGNAL(connected()),this,(sendData()));

sendData function

{
const unsigned char* src = some unsigned char data

this->tcpSocket->write(?,size) ?


}

tbscope
5th November 2010, 18:11
Just cast it to a char

Narasimha Reddy
19th July 2018, 07:38
tcpSocket->write((char*)src, size);