- //In Mainwindow 
- { 
- ui->setupUi(this); 
- Api *api = new Api(this); 
- Class1 *one = new Class1(this); 
- Class2 *two = new Class2(this); 
- Class3 *three = new Class3(this); 
- connect(timer, SIGNAL(timeout()), this, SLOT(findUpdate())); 
- timer->start(1000); 
- } 
-   
- void MainWindow::findUpdate() 
- { 
-   
- for(int i = 0; i < listone.size(); i++) 
- { 
-    one->update(i); 
-    one->updateLED(i); 
- } 
-   
- for(int i = 0; i < listtwo.size(); i++) 
- { 
-    two->updatePlot(i); 
-    two->updateLED(i); 
- } 
-   
- for(int i = 0; i < listthree.size(); i++) 
- { 
-    three->updatePlot(i); 
-    three->updateLED(i); 
- } 
- } 
-   
- //In ClassOne 
-  void ClassOne::update() 
- { 
-   updatePlot(); 
-   updateLED(); 
- } 
-   
- void ClassOne::updatePlot() 
- { 
-   api->getDataplotOne(url); 
-   connect(api,&Api::getDataPlotReplyOne,this,&ClassOne::updatePlotValue); 
- } 
-   
- void ClassOne::updateLED() 
- { 
-   api->getDataLEDOne(url); 
-   connect(api,&Api::getDataLEDOneReply,this,&ClassOne::updateLEDValue); 
- } 
-   
- //In ClassTwo 
-  void ClassTwo::update() 
- { 
-   updatePlot(); 
-   updateLED(); 
- } 
-   
- void ClassTwo::updatePlot() 
- { 
-   api->getDataplotTwo(url); 
-   connect(api,&Api::getDataPlotTwoReply,this,&ClassTwo::updatePlotValue); 
- } 
-   
- void ClassTwo::updateLED() 
- { 
-   api->getDataLEDTwo(url); 
-   connect(api,&Api::getDataLEDTwoReply,this,&ClassTwo::updateLEDValue); 
- } 
-   
-  void ClassThree::update() 
- { 
-   updatePlot(); 
-   updateLED(); 
- } 
-   
- void ClassThree::updatePlot() 
- { 
-   api->getDataplotThree(url); 
-   connect(api,&Api::getDataPlotThreeReply,this,&ClassThree::updatePlotValue); 
- } 
-   
-   
-   
- void ClassThree::updateLED() 
- { 
-   api->getDataLEDThree(url); 
-   connect(api,&Api::getDataLEDThreeReply,this,&ClassThree::updateLEDValue); 
- } 
-   
- // In Api Class 
- void-  Api ::getDataPlotOne(QString-  url )
 
- { 
- QNetworkRequest request (QUrl(- url ))- ; 
- QNetworkReply *reply = manager.get(request); 
- connect(reply,SIGNAL(finished()),this,SLOT(replydata1plot)); 
- } 
- void Api::replyData1plot() 
- { 
- QNetworkReply  *- reply  =-  qobject_cast<QNetworkReply *- > (QObject::sender())- ; 
- if(reply) 
- { 
- QJsonDocument json = QJsonDocument::fromJson(response.toUtf8()); 
- list = json.object(); 
- delete reply; 
- } 
- else 
- { 
- qDebug() << "Failure" << reply->errorString(); 
- delete reply; 
- } 
- emit getDataPlotReplyOne(list); 
- } 
-   
- void-  Api ::getDataLEDTwo(QString-  url )
 
- { 
- QNetworkRequest request (QUrl(- url ))- ; 
- QNetworkReply *reply = manager.get(request); 
- connect(reply,SIGNAL(finished()),this,SLOT(replydata2led)); 
- } 
- void Api::replyData1led() 
- { 
- QNetworkReply  *- reply  =-  qobject_cast<QNetworkReply *- > (QObject::sender())- ; 
- if(reply) 
- { 
- QJsonDocument json = QJsonDocument::fromJson(response.toUtf8()); 
- list = json.object(); 
- delete reply; 
- } 
- else 
- { 
- qDebug() << "Failure" << reply->errorString(); 
- delete reply; 
- } 
- emit getDataLEDReplyTwo(list); 
- } 
-   
- void Api::replyData2plot() 
- { 
- QNetworkReply  *- reply  =-  qobject_cast<QNetworkReply *- > (QObject::sender())- ; 
- if(reply) 
- { 
- QJsonDocument json = QJsonDocument::fromJson(response.toUtf8()); 
- list = json.object(); 
- delete reply; 
- } 
- else 
- { 
- qDebug() << "Failure" << reply->errorString(); 
- delete reply; 
- } 
- emit getDataPlotReplyTwo(list); 
- } 
-   
- void-  Api ::getDataLEDTwo(QString-  url )
 
- { 
- QNetworkRequest request (QUrl(- url ))- ; 
- QNetworkReply *reply = manager.get(request); 
- connect(reply,SIGNAL(finished()),this,SLOT(replydata2led)); 
- } 
- void Api::replyData2led() 
- { 
- QNetworkReply  *- reply  =-  qobject_cast<QNetworkReply *- > (QObject::sender())- ; 
- if(reply) 
- { 
- QJsonDocument json = QJsonDocument::fromJson(response.toUtf8()); 
- list = json.object(); 
- delete reply; 
- } 
- else 
- { 
- qDebug() << "Failure" << reply->errorString(); 
- delete reply; 
- } 
- emit getDataLEDReplyTwo(list); 
- } 
-   
- //As per your suggestion I need to use multiple QTimer. 
- connect(timerOnePlot, SIGNAL(timeout()), this, SLOT(findUpdateOnePlot())); 
        //In Mainwindow
void MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),UI(new Ui::MainWindow)
{
ui->setupUi(this);
Api *api = new Api(this);
Class1 *one = new Class1(this);
Class2 *two = new Class2(this);
Class3 *three = new Class3(this);
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(findUpdate()));
timer->start(1000);
}
void MainWindow::findUpdate()
{
QStringList listone = listOfdevice1;
QStringList listtwo = listOfdevice2;
QStringList listthree = listOfdevice3;
for(int i = 0; i < listone.size(); i++)
{
   one->update(i);
   one->updateLED(i);
}
for(int i = 0; i < listtwo.size(); i++)
{
   two->updatePlot(i);
   two->updateLED(i);
}
for(int i = 0; i < listthree.size(); i++)
{
   three->updatePlot(i);
   three->updateLED(i);
}
}
//In ClassOne
 void ClassOne::update()
{
  updatePlot();
  updateLED();
}
void ClassOne::updatePlot()
{
  api->getDataplotOne(url);
  connect(api,&Api::getDataPlotReplyOne,this,&ClassOne::updatePlotValue);
}
void ClassOne::updateLED()
{
  api->getDataLEDOne(url);
  connect(api,&Api::getDataLEDOneReply,this,&ClassOne::updateLEDValue);
}
//In ClassTwo
 void ClassTwo::update()
{
  updatePlot();
  updateLED();
}
void ClassTwo::updatePlot()
{
  api->getDataplotTwo(url);
  connect(api,&Api::getDataPlotTwoReply,this,&ClassTwo::updatePlotValue);
}
void ClassTwo::updateLED()
{
  api->getDataLEDTwo(url);
  connect(api,&Api::getDataLEDTwoReply,this,&ClassTwo::updateLEDValue);
}
 void ClassThree::update()
{
  updatePlot();
  updateLED();
}
void ClassThree::updatePlot()
{
  api->getDataplotThree(url);
  connect(api,&Api::getDataPlotThreeReply,this,&ClassThree::updatePlotValue);
}
void ClassThree::updateLED()
{
  api->getDataLEDThree(url);
  connect(api,&Api::getDataLEDThreeReply,this,&ClassThree::updateLEDValue);
}
// In Api Class
void Api::getDataPlotOne(QString url)
{
QNetworkRequest request(QUrl(url));
QNetworkReply *reply = manager.get(request);
connect(reply,SIGNAL(finished()),this,SLOT(replydata1plot));
}
void Api::replyData1plot()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
if(reply)
{
QString response = (QString)reply.realAll();
QJsonDocument json = QJsonDocument::fromJson(response.toUtf8());
list = json.object();
delete reply;
}
else
{
qDebug() << "Failure" << reply->errorString();
delete reply;
}
emit getDataPlotReplyOne(list);
}
void Api::getDataLEDTwo(QString url)
{
QNetworkRequest request(QUrl(url));
QNetworkReply *reply = manager.get(request);
connect(reply,SIGNAL(finished()),this,SLOT(replydata2led));
}
void Api::replyData1led()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
if(reply)
{
QString response = (QString)reply.realAll();
QJsonDocument json = QJsonDocument::fromJson(response.toUtf8());
list = json.object();
delete reply;
}
else
{
qDebug() << "Failure" << reply->errorString();
delete reply;
}
emit getDataLEDReplyTwo(list);
}
void Api::replyData2plot()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
if(reply)
{
QString response = (QString)reply.realAll();
QJsonDocument json = QJsonDocument::fromJson(response.toUtf8());
list = json.object();
delete reply;
}
else
{
qDebug() << "Failure" << reply->errorString();
delete reply;
}
emit getDataPlotReplyTwo(list);
}
void Api::getDataLEDTwo(QString url)
{
QNetworkRequest request(QUrl(url));
QNetworkReply *reply = manager.get(request);
connect(reply,SIGNAL(finished()),this,SLOT(replydata2led));
}
void Api::replyData2led()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender());
if(reply)
{
QString response = (QString)reply.realAll();
QJsonDocument json = QJsonDocument::fromJson(response.toUtf8());
list = json.object();
delete reply;
}
else
{
qDebug() << "Failure" << reply->errorString();
delete reply;
}
emit getDataLEDReplyTwo(list);
}
//As per your suggestion I need to use multiple QTimer.
QTimer* timerOnePlot=new QTimer(this);
connect(timerOnePlot, SIGNAL(timeout()), this, SLOT(findUpdateOnePlot()));
To copy to clipboard, switch view to plain text mode 
  //Now can you help me with a solution which wont effect my performance.
Bookmarks