I'm running into a slight problem making QwtPlots draw during click events. I can make QwtPlots show up just fine if I create them during (for example) the constructor for my form; however, if I try to create new plots from the click() slot of a button, the plots fail to draw.
I have a static class called Plotter that spits out QwtPlots for me.
Plotter
::buildSamplePlot(QWidget *parent
) { ...
myPlot.replot();
return myPlot;
}
Plotter::buildSamplePlot(QWidget *parent) {
QwtPlot *myPlot = new QwtPlot(QwtText("Two Curves"), parent);
...
myPlot.replot();
return myPlot;
}
To copy to clipboard, switch view to plain text mode
The following works fine when called from my constructor:
MainWindow::refresh() {
...
delete curPlot;
curPlot = Plotter::buildSamplePlot(ui->widgetGraph);
delete curPlot;
curPlot = Plotter::buildSamplePlot(ui->widgetGraph);
...
}
MainWindow::refresh() {
...
delete curPlot;
curPlot = Plotter::buildSamplePlot(ui->widgetGraph);
delete curPlot;
curPlot = Plotter::buildSamplePlot(ui->widgetGraph);
...
}
To copy to clipboard, switch view to plain text mode
I'm deleting the plot and re-creating it simply to show that I can delete and re-create plots just fine, as long as I do it from my form's constructor. However, calling the exact same method above from one of my button's click() slots does not work. All that happens is that the existing plot is deleted, but no new plot is drawn. I've stepped through and seen the the old plot really is deleted, and that a new plot is created (I can call methods on the new graph just fine). However, the newly created plot just doesn't seem to show up.
As far as I can tell, the plot exists but isn't drawing. I've tried forcing the plots to draw themselves by calling .repaint(), .replot(), and even .resize(). None of them had any effect.
Ideas?
Thanks,
-Evan Nelson
Bookmarks