title: qt c++ plot customplot from sqlite table
body: <p><a href="https://i.stack.imgur.com/31I64.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/31I64.jpg" alt="enter image description here"></a>I am new to Qt creator C++. I have designed a application where the data is displayed on a tableView fetching it from Sqlite database, till here i am successfull, but now i want to plot the graph on a customplot by giving values for x and y axis from the database which i have fetched it and displayed on tableView widget.Example: the data from my database is like Time and Temperature-Now i want to give values for X axis in Time and Y axis in Temperature, please help me out in the code-
  I am able to plot the graph normally as shown in the below code,how do i add the database values on x and y axis..</p>
  
  <pre><code>void MainWindow::makePlot()
  {
      QVector&lt;double&gt; x(100), y(101); 
  
  //    x[0]=1;Here I want the application to take the values from tableView,like 
                Time on X axis and Temp on Y axis. 
  //    x[1]=2;
  //    x[2]=3;
  //    x[3]=4;
  
  //    y[0]=1;
  //    y[1]=2;
  //    y[2]=3;
  //    y[3]=4;
  
      ui-&gt;customPlot-&gt;addGraph();
      ui-&gt;customPlot-&gt;graph(0)-&gt;setData(x, y);
      ui-&gt;customPlot-&gt;xAxis-&gt;setLabel("Time");
      ui-&gt;customPlot-&gt;yAxis-&gt;setLabel("Temp");
      ui-&gt;customPlot-&gt;xAxis-&gt;setRange(1, 15);
      ui-&gt;customPlot-&gt;yAxis-&gt;setRange(1, 15);
      ui-&gt;customPlot-&gt;replot();
  
  }
  
  Here is the code that displays the Database in tableView on push button.
  void MainWindow::on_pushButton_clicked()
  {
      MainWindow conn;
      QSqlQueryModel * modal=new QSqlQueryModel();
      conn.connOpen();
      QSqlQuery* qry=new QSqlQuery(conn.mydb);
      qry-&gt;prepare("select * from empdata");
      qry-&gt;exec();
      modal-&gt;setQuery(*qry);
      ui-&gt;tableView-&gt;setModel(modal);
      conn.connClose();
      qDebug() &lt;&lt;(modal-&gt;rowCount());
  }[![enter image description here][1]][1]
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mjZDi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mjZDi.jpg" alt="output of the above code"></a></p>
  
  <p>Please help me out..Thanks in advance..</p>
  
  <p><a href="https://i.stack.imgur.com/mjZDi.jpg" rel="nofollow noreferrer">enter image description here</a></p>