@JonB
Last edit my code :
DataReceiver::DataReceiver(QObject *parent)
: QObject{parent}
{
_manager.setAutoDeleteReplies(true);
}
void DataReceiver::start()
{
_connection++;
if(_connection > 1)
return;
_takeData = true;
run();
}
void DataReceiver::stop()
{
_takeData = false;
_connection = 0;
_data.clear();
}
void DataReceiver::getData()
{
_data.clear();
QString url = QString("http://localhost:%1/sample").arg(_port);
QUrl _apiUrl(url);
QNetworkRequest _request(_apiUrl);
_reply = _manager.get(_request);
connect(_reply, &QNetworkReply::readyRead, this, &DataReceiver::onReadReady);
connect(_reply, &QNetworkReply::finished, this, &DataReceiver::onFinished);
}
void DataReceiver::run()
{
if(!_takeData)
return;
getData();
}
void DataReceiver::onReadReady()
{
_data += _reply->readAll();
}
void DataReceiver::onFinished()
{
emit sendData(_data);
run();
}
its working. time slow down from 65ms to 165ms but its working.