title: Update gui using signal/slot in qt
body: <p>I am taking data from socket in which some paramaters are changing after every second. I am projecting the data on my gui. I want to update my gui after every second.   </p>
  
  <p>This is my sockettest class where i am receving the data and i want to plot the data in tactical widget.</p>
  
  <pre><code>  void socketTest::readyRead()
    {
  
      //QByteArray buffer;
      int numRead = 0, numReadTotal = 0;
      char buffer[180];
  
       socketTest *a = new socketTest();
       tacticalwidget *b = new tacticalwidget();
  
      forever {
          numRead  = socket-&gt;read(buffer, 180);
  
          // do whatever with array
  
          numReadTotal += numRead;
          memcpy (detailed_track_data, buffer, sizeof(buffer));
          //qDebug() &lt;&lt; sizeof(buffer);
          amp = qToBigEndian(detailed_track_data[0].amplitude);
          theta = qToBigEndian(detailed_track_data[0].doa)*0.1;
  
          emit SIGNAL(valuechanged());
          connect(a,SIGNAL(valuechanged()), b , SLOT(tacticalwidget::paintEvent()));
  
          int track_state = qToBigEndian(detailed_track_data[0].track_status);
          int bit1 = 2^5;
          int bit2 = 2^4;
  
          //check hostility level for hostile
          if(((track_state) &amp; (bit1)) == 0 &amp;&amp; ((track_state) &amp; (bit2)) == 1)
              tracktype = 0;// Hostile
              else
                 //check hostility level for unknown
                  if(((track_state) &amp; (bit1)) == 0 &amp;&amp; ((track_state) &amp; (bit2)) == 0)
                          tracktype = 1;//unknown
                   else
                      tracktype = 2;//friendly
  
          if (numRead == 0 &amp;&amp; !socket-&gt;waitForReadyRead())
              break;
      }
  </code></pre>
  
  <p>TacticalWidget code:</p>
  
  <pre><code>    void tacticalwidget::paintEvent(QPaintEvent */*e*/)
        {
  
         QSize sz = size();
         int radius;
  
         QPainter painter(this);
         painter.setRenderHint(QPainter::Antialiasing,true);
  
         QBrush br;
         br.setColor(Qt::black);
  
          painter.setBrush(br);
          painter.fillRect(0,0,sz.width(),sz.height(),Qt::SolidPattern);
  
          int centrex = sz.width()/2 ;
          int centrey = sz.height()/2;
  
          if (centrex &lt; centrey )
            radius = centrex -4;
           else
           radius = centrey -4;
  
  
           painter.setPen(QPen(Qt::green,2,Qt::SolidLine,Qt::RoundCap));
           painter.drawEllipse(centrex - radius,centrey - radius,2*radius,2*radius);
  
           painter.setPen(QPen(Qt::yellow,2,Qt::SolidLine,Qt::RoundCap));
           painter.drawEllipse(centrex - (radius*2/3),centrey-radius*2/3),(radius*4  /3),(radius*4/3));
  
         painter.setPen(QPen(Qt::red,2,Qt::SolidLine,Qt::RoundCap));
         painter.drawEllipse(centrex - radius/3,centrey - radius/3,radius*2/3,radius*2/3);
  
  
          painter.setPen(QPen(Qt::white,2,Qt::SolidLine,Qt::RoundCap));
         painter.drawLine(centrex,0,centrex,centrey*2);
          painter.drawLine(0,centrey,centrex*2,centrey);
  
         painter.drawText(centrex - radius + 4,centrey,"270");
      painter.drawText(centrex,centrey-radius + 4 ,"N");
      painter.drawText(centrex,centrey+radius -4,"180");
      painter.drawText(centrex + radius -4,centrey,"90");
  
      painter.setPen(QPen(Qt::magenta,2,Qt::SolidLine,Qt::RoundCap));
      double theta = 45 * PI /180;
      painter.drawLine(centrex,centrey,centrex + radius * sin(theta),centrey - radius  *       cos(theta));
  
      //Track Display
  
      double amplitudefactor = (theObj.amp + 80)/100;
      //int trackNo = i+1;
      double pointx,pointy;
      int circleradius,innerradius = 0;
  
      switch(theObj.tracktype)
      {
      case 0://hostile
          circleradius = radius/3;
          pointx =centrex + circleradius * sin(theObj.theta) * amplitudefactor;
          pointy = centrey - circleradius * cos(theObj.theta)* amplitudefactor;
  
          painter.setPen(QPen(Qt::red,2,Qt::SolidLine,Qt::RoundCap));
          painter.drawImage(pointx,pointy,QImage("E:\\bitmaps\\rbitmap.png"));
          break;
      case 1://unknown
          circleradius = radius/3;
          innerradius = radius/3;
  
          pointx =centrex + innerradius * sin(theObj.theta) + circleradius *    sin(theObj.theta) * amplitudefactor;
          pointy = centrey - innerradius * cos(theObj.theta) - circleradius * cos(theObj.theta)* amplitudefactor;
  
          painter.setPen(QPen(Qt::yellow,2,Qt::SolidLine,Qt::RoundCap));
          painter.drawImage(pointx,pointy,QImage("E:\\bitmaps\\ybitmap.png"));
          break;
      case 2: //friendly
          circleradius = radius/3;
          innerradius = radius *2/3;
  
          pointx =centrex + innerradius * sin(theObj.theta) + circleradius * sin(theObj.theta) * amplitudefactor;
          pointy = centrey - innerradius * cos(theObj.theta) - circleradius * cos(theObj.theta)* amplitudefactor;
  
          painter.setPen(QPen(Qt::green,2,Qt::SolidLine,Qt::RoundCap));
          painter.drawImage(pointx,pointy,QImage("E:\\bitmaps\\gbitmap.png"));
          break;
      default:
          break;
  
  
  
      }
     // setStyleSheet("background-color: rgb(0, 0, 0);");
  }
  </code></pre>