Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QWT Plot does not update
Forum Updated to NodeBB v4.3 + New Features

QWT Plot does not update

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
1 Posts 1 Posters 480 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    codeaway
    wrote on last edited by
    #1

    Greetings,

    Have QWT 6.1.5, QT 5.15.0 and MSVC2019, trying to do a plot:

    void MainWindow::setupGraph()
    {
    	QColor c(Qt::black);
    	c.setAlpha(140);
    
    	QPalette pal;
    	pal.setColor(QPalette::Window, c);
    
    	ui->qwtPlot->setTitle("Monitor");
    	ui->qwtPlot->setAxisTitle(QwtPlot::xBottom, "Sec");
    	ui->qwtPlot->setAxisScale(QwtPlot::xBottom, 0, 100, 10);
    	ui->qwtPlot->setAxisTitle(QwtPlot::yLeft, "mV");		// Y axis title
    	ui->qwtPlot->setAxisScale(QwtPlot::yLeft, 0, 100, 10);
    	ui->qwtPlot->setAttribute(Qt::WA_TranslucentBackground);	// background colour
    	ui->qwtPlot->setPalette(pal);
    
    
    	QwtPlotGrid *grid = new QwtPlotGrid();
    	grid->setMajorPen(QPen(Qt::darkGray, 0, Qt::DotLine));		// grid is black dotted
    	grid->attach(ui->qwtPlot);
    
    	curve = new QwtPlotCurve;
    	curve->setPen(QPen(Qt::green));					// plot is green
    	curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);	// plot anti aliased
    	curve->attach(ui->qwtPlot);
    }
    
    void MainWindow::updateGraph()
    {
    	int i = 0;
    
    	while (1) {
    		sec[i] = seconds;
    		qDebug() << "Sec:" << sec[i] << "," << "Ch0:" << ch[i];
    		seconds++;
    		i++;
    		if (i == 5)
    			break;
    	}
    
    	curve->setSamples((double *) sec, (double *) ch, 5);
    	curve->attach(ui->qwtPlot);
    	ui->qwtPlot->replot();
    }
    

    From my MainWindow, I do setupGraph();
    and as I get data, I do an updateGraph();

    The qDebug() debug log messages I can see:

    Sec: 0 , Ch0: 21
    Sec: 1 , Ch0: 24
    Sec: 2 , Ch0: 20
    Sec: 3 , Ch0: 23
    Sec: 4 , Ch0: 22
    Sec: 5 , Ch0: 21
    Sec: 6 , Ch0: 21
    ....

    But the Graph does not seem to plot any points ?
    I can see that the Plot has setup correctly with the set values in setupGraph()

    Am I missing something in here ?

    Thanks,

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved