I have had time to further look at my problem and find the solution.
In reality I didn´t see that the line of the curve within the legend was plotted, because the line has a light yellow colour and the background is light gray. The line is also very short.
I added a curve title which is now displayed as assumed and so fix the view onto the legend.
I have attached the revised code below.
Uwe, I am aware that in a normal case it is necessary to allocate the memory on the heap, this was a fast evaluation how to mix SigLib and Qwt, and I only had a main function, so allocating on the stack was OK for that peculiar purpose.
Anyway, now I am going to clone the SigLib graphics function written with SignalVisualize/wxWidgets with Qt/Qwt, and there of course I´ll use the approach recommended by you.
// plot object
myPlot.setTitle( "Autospektrum!" );
myPlot.
setAxisTitle( QwtPlot::xBottom,
"frequency bin" );
myPlot.
setAxisTitle( QwtPlot::yLeft,
"log Amplitude" );
myPlot.
setCanvasBackground( QColor( Qt
::darkBlue ));
// grid
grid.enableXMin( true );
grid.
setMajPen( QPen( Qt
::white,
0, Qt
::DotLine ));
grid.
setMinPen( QPen( Qt
::gray,
0 , Qt
::DotLine ));
grid.attach( &myPlot );
// define the curve object
curve.setSamples( pXData, pResults, FFT_LENGTH );
curve.
setPen( QPen( Qt
::yellow ));
curve.setTitle("Sinus");
curve.attach( &myPlot );
// legend
myPlot.
insertLegend( &legend,
QwtPlot::RightLegend );
//myPlot.replot();
myPlot.show();
// plot object
QwtPlot myPlot;
myPlot.setTitle( "Autospektrum!" );
myPlot.setAxisTitle( QwtPlot::xBottom, "frequency bin" );
myPlot.setAxisTitle( QwtPlot::yLeft, "log Amplitude" );
myPlot.setCanvasBackground( QColor( Qt::darkBlue ));
// grid
QwtPlotGrid grid;
grid.enableXMin( true );
grid.setMajPen( QPen( Qt::white, 0, Qt::DotLine ));
grid.setMinPen( QPen( Qt::gray, 0 , Qt::DotLine ));
grid.attach( &myPlot );
// define the curve object
QwtPlotCurve curve;
curve.setSamples( pXData, pResults, FFT_LENGTH );
curve.setPen( QPen( Qt::yellow ));
curve.setRenderHint( QwtPlotItem::RenderAntialiased );
curve.setTitle("Sinus");
curve.setLegendAttribute( QwtPlotCurve::LegendShowLine );
curve.attach( &myPlot );
// legend
QwtLegend legend;
myPlot.insertLegend( &legend, QwtPlot::RightLegend );
//myPlot.replot();
myPlot.show();
To copy to clipboard, switch view to plain text mode
Bookmarks