QwtPlot is derive from a couple of classes of which QFrame is one.When you call a painting method (e.g. replot()) on an instance of QwtPlot, you are ordering repainting of the widget QwtPlot. Not a main window.QFrame class is the base class of widgets that can have a frame
You need to try something like this
MainWindow w;
w.setCentralWidget(myPlot);
If you need to add a curve to a plot on button click, do something like this..
connent(addCurveButton, SIGNAL(clicked()), myPlot, SLOT(addCurve()));
Where myPlot is an instance of MyPlot. MyPlot being a subclass of QwtPlot that declares a Slot addCurve.
The implementation of addCurve should go like this...
void MyPlot::addCurve()
{
//get the curve info (e.g. 1) open and read a file to get coordinates,
//2) launch a dialog that allows a vector of points to be generated based on some input)
QwtPlotCurve * curve = new QwtPlotCurve (name);
curve->setSamples(_samples) ;
curve->attach(this);
replot();
}
Bookmarks