title: Qt call to update not triggering call to paintEvent() while drawing data from serial port to scrollArea
body: <p>I am newbie to Qt 5.1.0. My problem with Qt is showed directly as follows. Data from serial port is received by readdata(), then call the draw() in mainwindow.cpp to deliver the data to newpaint() in paint.cpp. Two classes are created in this project:class mainwindow is mainly responsible for receiving data from serial port,class paint is for drawing the data (actually the data is coordinates of a mathematical function) on the scroll area widget which is on the mainwindow.</p>
  
  <p>But in paint.cpp, paintevent is not invoked by update().UpdateEnabled() returns true depicting that the problem doesn't exist in the use of update().</p>
  
  <p>Main part is pasted below.</p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      QPainterPath linepath;
      linepath.moveTo(0,0);
      ui-&gt;setupUi(this);
      paintwiget=new paint(linepath,ui-&gt;scrollArea);
      ui-&gt;scrollArea-&gt;setWidget(paintwiget);
      paintwiget-&gt;show();
      ui-&gt;closeserial-&gt;setEnabled(false);
      ui-&gt;sendData-&gt;setEnabled(false);
  
      serial=new QSerialPort(this);
  
  
       connect(serial,SIGNAL(readyRead()),this,SLOT(readData()));
  
  
  }
  
  
     void paint::newpaint(qreal *aa1, int len1)
     {
         if (!aa.isEmpty())
             aa.clear();
        int i;
        for (i=0;i&lt;len1;i++)
            aa.append(aa1[i]);
       // qDebug()&lt;&lt;aa.size();
        //qDebug()&lt;&lt;"aa[0:3]"&lt;&lt;aa[0]&lt;&lt;" "&lt;&lt;aa[1]&lt;&lt;" "&lt;&lt;aa[2]&lt;&lt;" "&lt;&lt;aa[3];
            len=len1;
  //          this-&gt;setVisible(true);
             qDebug()&lt;&lt;this-&gt;isVisible();//now returns true
            this-&gt;update();
  
  
            //qDebug()&lt;&lt;"okla";
  
     }
     void paint::paintEvent(QPaintEvent *)
     {
         qDebug()&lt;&lt;"ok~~";
         QPointF currentpoi;
         QPainter painter(this);
         int ii=0;
         qDebug()&lt;&lt;len;
         for (ii=0;ii&lt;len/2;ii++)
         {
             currentpoi=path.currentPosition();
             qDebug()&lt;&lt;"currentpoi"&lt;&lt;currentpoi;
             path.moveTo(currentpoi);
             path.lineTo(aa[2*ii],aa[2*ii+1]);
        // painter.setRenderHint(QPainter::Antialiasing);
             painter.drawPath(path);
          }
     }
  </code></pre>
  
  <p><strong>paint.h</strong></p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QWidget&gt;
  #include &lt;QPainter&gt;
  #include &lt;QTabWidget&gt;
  //#include &lt;mainwindow.h&gt;
  
  class paint : public QWidget
  {
  public:
    explicit paint(QPainterPath &amp;path,QWidget *parent=0);
  void newpaint(qreal *,int);
  QVector &lt;qreal&gt;aa;
  int len;
  QWidget *parent;
  
  private:
  
    QPointF point;
   QPainterPath path;
  protected:
   void paintEvent(QPaintEvent *event);
  
  };
  </code></pre>