<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[how to get current updated time at each tickerlabel in x axis  data plot]]></title><description><![CDATA[<p dir="auto">here is my code,but i am getting updated time at all ticker<br />
please help</p>
<p dir="auto">void MainWindow::init_plot()<br />
{<br />
ui-&gt;plot-&gt;xAxis-&gt;setLabel("t [hh:mm:ss]");<br />
ui-&gt;plot-&gt;yAxis-&gt;setLabel("V [mV]");</p>
<pre><code>ui-&gt;plot-&gt;addGraph(); // blue line
ui-&gt;plot-&gt;graph(0)-&gt;setPen(QPen(Qt::blue));
ui-&gt;plot-&gt;addGraph(); // red line
ui-&gt;plot-&gt;graph(1)-&gt;setPen(QPen(Qt::red));
ui-&gt;plot-&gt;addGraph(); // green line
ui-&gt;plot-&gt;graph(2)-&gt;setPen(QPen(Qt::green));

ui-&gt;plot-&gt;axisRect()-&gt;setupFullAxesBox();
ui-&gt;plot-&gt;yAxis-&gt;setRange(0, 100);

// make left and bottom axes transfer their ranges to right and top axes:
connect(ui-&gt;plot-&gt;xAxis, SIGNAL(rangeChanged(QCPRange)), ui-&gt;plot-&gt;xAxis2, SLOT(setRange(QCPRange)));
connect(ui-&gt;plot-&gt;yAxis, SIGNAL(rangeChanged(QCPRange)), ui-&gt;plot-&gt;yAxis2, SLOT(setRange(QCPRange)));

// setup a timer that repeatedly calls MainWindow::realtimeDataSlot:
connect(&amp;dateTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot()));
dateTimer.start(0);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void MainWindow::realtimeDataSlot()<br />
{</p>
<pre><code>QSharedPointer&lt;QCPAxisTickerTime&gt; timeTicker(new QCPAxisTickerTime);
QTime ti = QTime::currentTime();
QString tim = ti.toString("hh:mm:ss");
timeTicker-&gt;setTimeFormat(tim);
ui-&gt;plot-&gt;xAxis-&gt;setTicker(timeTicker);


static QTime time=QTime::currentTime();
ui-&gt;spinBox_2-&gt;setValue(ui-&gt;spinBox-&gt;text().toInt()+10);
ui-&gt;spinBox_3-&gt;setValue(ui-&gt;spinBox-&gt;text().toInt()-20);

// calculate two new data points:
double key = time.elapsed()/1000.0; // time elapsed since start of demo, in seconds
static double lastPointKey = 0;

if (key-lastPointKey &gt; 0.002) // at most add point every 1s
{

  // add data to lines:
  ui-&gt;plot-&gt;graph(0)-&gt;addData(key, ui-&gt;spinBox-&gt;text().toInt());
  ui-&gt;plot-&gt;graph(1)-&gt;addData(key, ui-&gt;spinBox-&gt;text().toInt()+10);
  ui-&gt;plot-&gt;graph(2)-&gt;addData(key, ui-&gt;spinBox-&gt;text().toInt()-20);
  lastPointKey = key;
}
// make key axis range scroll with the data (at a constant range size of 8):
if(ui-&gt;pushButton-&gt;text()=="stop")
{
  ui-&gt;plot-&gt;xAxis-&gt;setRange(key, 8, Qt::AlignRight);
  ui-&gt;plot-&gt;replot();
}
</code></pre>
<p dir="auto">}</p>
<p dir="auto">please anyone give the solution..</p>
]]></description><link>https://forum.qt.io/topic/92514/how-to-get-current-updated-time-at-each-tickerlabel-in-x-axis-data-plot</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 08:33:24 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/92514.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Jul 2018 12:02:13 GMT</pubDate><ttl>60</ttl></channel></rss>